Don't use deprecated 'U' flag to read manifest#623
Conversation
The universal newlines mode ('U' flag) is deprecated since Python
3.4. It only replaces "\r\n" with "\n", but it doesn't split lines at
"\r" (Mac newline). In practice, the flag was useless, the
sdist.read_manifest() method already uses line.strip() and so removes
newline characters.
|
I vaguely recall experimenting with this before and finding we couldn't drop it for some reason. Can we be sure the U doesn't affect other aspects such as text encoding? |
|
New test on Python 2: Oh wait: replacing "rbU" with "rb" doesn't work for Mac newline (\r) :-/ I made a mistake in my previous test. Test on Python 3: On Python 3, the "U" flag is simply ignored for binary mode and Mac newlines don't work as expected. |
|
"All checks have passed" If setuptools must support Mac newlines, at least one unit test must be added, no? |
|
I'm all but certain we don't need to support Mac newlines any longer. I agree about the tests, with the caveat that setuptools has never had suitable use-case coverage, so we have to be extra considerate. In this case, let's make the change and if someone complains, we'll add the necessary test. |
The universal newlines mode ('U' flag) is deprecated since Python
3.4. It only replaces "\r\n" with "\n", but it doesn't split lines at
"\r" (Mac newline). In practice, the flag was useless, the
sdist.read_manifest() method already uses line.strip() and so removes
newline characters.
Example of warning:
.../setuptools/command/sdist.py:182: DeprecationWarning: 'U' mode is deprecated
manifest = open(self.manifest, 'rbU')