]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-105931: Fix surprising compileall stripdir behaviour (GH-108671)
authorhetmankp <728670+hetmankp@users.noreply.github.com>
Mon, 23 Oct 2023 13:55:39 +0000 (00:55 +1100)
committerGitHub <noreply@github.com>
Mon, 23 Oct 2023 13:55:39 +0000 (13:55 +0000)
commit3726cb0f146cb229a5e9db8d41c713b023dcd474
treefff1e2739ff14c0fa8c54c1e084c53079885ff58
parent52e902ccf0178d7a3f26de4bba7922b01c0d4d3c
gh-105931: Fix surprising compileall stripdir behaviour (GH-108671)

Before, the '-s STRIPDIR' option on
compileall lead to some surprising results as it only strips away
path components that match, but leaves alone the non-matching ones
interspersed in between.

For example, with: python -m compileall -s/path/to/another/src
/path/to/build/src/file.py

The resulting written path will be: build/file.py

This fix only strips directories that are a fully matching prefix of the
source path. If a stripdir is provided that is not a valid prefix, a
warning will be displayed (which can be silenced with '-qq').
Lib/compileall.py
Lib/test/test_compileall.py
Misc/NEWS.d/next/Library/2023-08-30-19-10-35.gh-issue-105931.Lpwve8.rst [new file with mode: 0644]