diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-10-15 09:26:13 (GMT) |
---|---|---|
committer | Petr Viktorin <encukou@gmail.com> | 2019-10-15 09:26:13 (GMT) |
commit | eb1dda2b56f67f09352c303588c28880c471ae87 (patch) | |
tree | 210de1a151a566aa36935b36280811a8e2867040 /Lib/compileall.py | |
parent | 0b60f64e4343913b4931dc27379d9808e5b78fe1 (diff) | |
download | cpython-eb1dda2b56f67f09352c303588c28880c471ae87.zip cpython-eb1dda2b56f67f09352c303588c28880c471ae87.tar.gz cpython-eb1dda2b56f67f09352c303588c28880c471ae87.tar.bz2 |
bpo-38470: Fix test_compileall.test_compile_dir_maxlevels() (GH-16789)
Fix test_compile_dir_maxlevels() on Windows without long path
support: only create 3 subdirectories instead of between 20 and 100
subdirectories.
Fix also compile_dir() to use the current sys.getrecursionlimit()
value as the default maxlevels value, rather than using
sys.getrecursionlimit() value read at startup.
Diffstat (limited to 'Lib/compileall.py')
-rw-r--r-- | Lib/compileall.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Lib/compileall.py b/Lib/compileall.py index 26caf34..8cfde5b 100644 --- a/Lib/compileall.py +++ b/Lib/compileall.py @@ -19,11 +19,9 @@ import struct from functools import partial from pathlib import Path -RECURSION_LIMIT = sys.getrecursionlimit() - __all__ = ["compile_dir","compile_file","compile_path"] -def _walk_dir(dir, maxlevels=RECURSION_LIMIT, quiet=0): +def _walk_dir(dir, maxlevels, quiet=0): if quiet < 2 and isinstance(dir, os.PathLike): dir = os.fspath(dir) if not quiet: @@ -46,7 +44,7 @@ def _walk_dir(dir, maxlevels=RECURSION_LIMIT, quiet=0): yield from _walk_dir(fullname, maxlevels=maxlevels - 1, quiet=quiet) -def compile_dir(dir, maxlevels=RECURSION_LIMIT, ddir=None, force=False, +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, prependdir=None, limit_sl_dest=None): @@ -83,6 +81,8 @@ def compile_dir(dir, maxlevels=RECURSION_LIMIT, ddir=None, force=False, from concurrent.futures import ProcessPoolExecutor except ImportError: workers = 1 + if maxlevels is None: + maxlevels = sys.getrecursionlimit() files = _walk_dir(dir, quiet=quiet, maxlevels=maxlevels) success = True if workers != 1 and ProcessPoolExecutor is not None: @@ -285,7 +285,7 @@ def main(): parser = argparse.ArgumentParser( description='Utilities to support installing Python libraries.') parser.add_argument('-l', action='store_const', const=0, - default=RECURSION_LIMIT, dest='maxlevels', + default=None, dest='maxlevels', help="don't recurse into subdirectories") parser.add_argument('-r', type=int, dest='recursion', help=('control the maximum recursion level. ' |