bpo-36998: Fix distutils' sdist command for undecodable filenames #13467
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.


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