gracefully handle unicode surrogate bogosity in pmap.py #1322
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.
Suggestion cannot be applied right now. Please check back later.
Lately, while running 5.4.6 unit-tests on Python 3.6, I discovered the test_pmap case failing due to scripts/pmap.py barfing on some fugly Unicode sequences. Apparently, ext4 on Linux can have some oddball Unicode embedded in filenames that Python 3.6.3 rejects with complaints about surrogate characters. Specifically, the offending paths appear to be transient testfn tmpfiles that happen to be mapped within the interpreter when test_pmap.py acts on it, with pathnames like 'build/$testfnf\udcc0\udc80dxyit7fq.so'.
I'm not sure which other testcase creates these files, but if I run the affected test_pmap case by itself, it will happily succeed. It only seems to fail when I run the test suite in its entirety. For background, the testbed is an arm64 system, running a custom Linux distro with a mostly-vanilla 4.16.15 kernel.
For now the most robust way I can see to handle this is catch the exception and fall back on running the offending pathname through repr(). It appears to produce sane pmap.py output and pass tests on Python 2.7.15 and 3.6.3.