Description
The '-s' stripdir parameter to compileall has very unusual semantics that could lead to unexpected and potentially confusing outcomes.
For example, when run like this: python -m compileall -s/path/to/build/dst -p /lib /path/to/build/src/file.py
The source file path written to the compiled file will be: /lib/src/file.py
. In other words the source file path is partially stripped even though the strip prefix doesn't fully match the source file path. Since this was introduced in #16012 I'd like to get @frenzymadness to comment if this was intentional, because it seems that it could be a source of really confusing bugs for end users who accidentally misspell something in their invocation and get a partially stripped result.
It gets weirder than that however, when run like this: python -m compileall -s/path/to/another/src -p /lib /path/to/build/src/file.py
The source file path written to the compiled file will be: /lib/build/file.py
. The matching directories are removed around the non-matching ones. Even if there was some reason for the first behaviour it seems this second one is absolutely not a good idea.
I'm happy to fix this once it is confirmed this behaviour is unintentional.