Visitar URL original
bpo-36998: Fix distutils' sdist command for undecodable filenames by abadger · Pull Request #13467 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20221223171504/https://github.com/python/cpython/pull/13467
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

bpo-36998: Fix distutils' sdist command for undecodable filenames #13467

Closed
wants to merge 3 commits into from

Conversation

abadger
Copy link
Contributor

@abadger abadger commented May 21, 2019 •

It is occassionally desirable to have undecodable filenames inside of an sdist.
For instance, testcases may want to use a filename that is undecodable to
simulate what the application will see in real-world usage. Prior to this
change, distutils was correctly reading the filename from disk (using the
surrogatescape error handler to handle the undecodable bytes) but failing to
write the filename back out to the MANIFEST file because the characters could
not be encoded. This change fixes that by using the surrogateescape error
handler at the point that we write the filenames out, matching with the reading
of the data.

https://bugs.python.org/issue36998

It is occassionally desirable to have undecodable filenames inside of an sdist.
For instance, testcases may want to use a filename that is undecodable to
simulate what the application will see in real-world usage.  Prior to this
change, distutils was correctly reading the filename from disk (using the
surrogatescape error handler to handle the undecodable bytes) but failing to
write the filename back out to the MANIFEST file because the characters could
not be encoded.  This change fixes that by using the surrogateescape error
handler at the point that we write the filenames out, matching with the reading
of the data.
When the MANIFEST is regenerated, the existing MANIFEST needs to be read
with the surrogateescape error handler.  Otherwise, undecodable
filenames will cause this to error.
@abadger abadger force-pushed the fix-manifest-writing-undecodable branch from 95f45e5 to a91f8f7 Compare May 22, 2019
On Windows, filenames must be decodable as they are treated as human
characters, not as a sequene of bytes.  Therefore, the MANIFEST
generated on Windows can never hold undecodable bytes (and will mess
them up if they are present) so we can safely skip that test there.
@abadger abadger force-pushed the fix-manifest-writing-undecodable branch from a91f8f7 to 5687c6d Compare May 22, 2019
auvipy
auvipy approved these changes May 31, 2019
@pganssle
Copy link
Member

pganssle commented Sep 11, 2019

@abadger This looks like a very nice pull request, but these days distutils is more or less frozen and not accepting new changes. The recommended guidance is to send bugs and fixes to setuptools instead, because of 1. backwards compatibility concerns and 2. the fact that setuptools supports old versions of Python immediately (and as such this comes with a backport "for free"). Eventually setuptools will become the reference implementation for distutils.

As a maintainer of setuptools, I think this does look like a reasonable change to make, so I don't think you'd be wasting your time by adapting the patch to our codebase.

@jaraco jaraco removed the request for review from vstinner Sep 11, 2019
@iritkatriel
Copy link
Member

iritkatriel commented May 29, 2021

Closing this PR following the closure of its b.p.o issue (https://bugs.python.org/issue36998)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants