X Tutup
The Wayback Machine - https://web.archive.org/web/20220929142931/https://github.com/python/cpython/issues/97544
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: illegal newline value on 0x85 (NEL) #97544

Open
jaraco opened this issue Sep 25, 2022 · 1 comment
Open

ValueError: illegal newline value on 0x85 (NEL) #97544

jaraco opened this issue Sep 25, 2022 · 1 comment
Labels
type-bug An unexpected behavior, bug, or error

Comments

@jaraco
Copy link
Member

jaraco commented Sep 25, 2022

In attempting to harmonize the path pie implementation with more modern constructs, I'm seeking also to utilize the newline argument to open instead of explicitly substituting characters.

When I do, however, I find that some tests start to fail when NEL is passed as a newline character:

$ py -c "open('foo', 'w', newline='\x85')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: illegal newline value: �

At least in some contexts, Python recognizes NEL as a line separator:

>>> 'a\x85b\x1ec'.splitlines()
['a', 'b', 'c']

See also #66428 for some background.

According to the wikipedia article, a conforming application should honor a number of characters as newlines:

>>> newlines = '\x0a', '\x0b', '\x0c', '\x0d', '\x0d\x0a', '\u0085', '\u2028', '\u2029'
>>> for candidate in newlines:
...   try: x=open('foo', 'w', newline=candidate)
...   except ValueError: print('failed on', repr(candidate))
... 
failed on '\x0b'
failed on '\x0c'
failed on '\x85'
failed on '\u2028'
failed on '\u2029'
@jaraco jaraco added the type-bug An unexpected behavior, bug, or error label Sep 25, 2022
@larryhastings
Copy link
Contributor

larryhastings commented Sep 26, 2022

The documentation for open:

https://docs.python.org/3/library/functions.html#open

is quite specific in what it supports:

newline controls how universal newlines mode works (it only applies to text mode). It can be None, '', '\n', '\r', and '\r\n'.

Since '\x85' is not among those specific legal values, I don't think this is a bug. It might be a reasonable feature request, though.

Which specific Wikipedia article are you referring to? There's more than one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants
X Tutup