diff options
author | Gregory P. Smith <greg@krypto.org> | 2020-02-28 17:28:37 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-28 17:28:37 -0800 |
commit | 02673352b5db6ca4d3dc804965facbedfe66425d (patch) | |
tree | 24ac954d0b1d8b377fd0de065778717204fe5507 /Lib/compileall.py | |
parent | 03153dd1459fab94f294a118ed1525e34d58601a (diff) | |
download | cpython-02673352b5db6ca4d3dc804965facbedfe66425d.tar.gz cpython-02673352b5db6ca4d3dc804965facbedfe66425d.zip |
bpo-39769: Fix compileall ddir for subpkgs. (GH-18676)
Fix compileall.compile_dir() ddir= behavior on sub-packages.
Fixes compileall.compile_dir's ddir parameter and compileall command
line flag `-d` to no longer write the wrong pathname to the generated
pyc file for submodules beneath the root of the directory tree being
compiled. This fixes a regression introduced with Python 3.5.
Also marks the _new_ in 3.9 from PR #16012 parameters to compile_dir as keyword only (as that is the only way they will be used) and fixes an omission of them in one place from the docs.
Diffstat (limited to 'Lib/compileall.py')
-rw-r--r-- | Lib/compileall.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/compileall.py b/Lib/compileall.py index 8cfde5b7b3e..1831ad749f2 100644 --- a/Lib/compileall.py +++ b/Lib/compileall.py @@ -46,7 +46,7 @@ def _walk_dir(dir, maxlevels, quiet=0): def compile_dir(dir, maxlevels=None, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, workers=1, - invalidation_mode=None, stripdir=None, + invalidation_mode=None, *, stripdir=None, prependdir=None, limit_sl_dest=None): """Byte-compile all modules in the given directory tree. @@ -72,6 +72,13 @@ def compile_dir(dir, maxlevels=None, ddir=None, force=False, the defined path """ ProcessPoolExecutor = None + if ddir is not None and (stripdir is not None or prependdir is not None): + raise ValueError(("Destination dir (ddir) cannot be used " + "in combination with stripdir or prependdir")) + if ddir is not None: + stripdir = dir + prependdir = ddir + ddir = None if workers < 0: raise ValueError('workers must be greater or equal to 0') if workers != 1: @@ -111,7 +118,7 @@ def compile_dir(dir, maxlevels=None, ddir=None, force=False, def compile_file(fullname, ddir=None, force=False, rx=None, quiet=0, legacy=False, optimize=-1, - invalidation_mode=None, stripdir=None, prependdir=None, + invalidation_mode=None, *, stripdir=None, prependdir=None, limit_sl_dest=None): """Byte-compile one file. |