]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #28485: Check for negative workers even without ProcessPoolExecutor
authorMartin Panter <vadmium+py@gmail.com>
Sat, 5 Nov 2016 01:11:36 +0000 (01:11 +0000)
committerMartin Panter <vadmium+py@gmail.com>
Sat, 5 Nov 2016 01:11:36 +0000 (01:11 +0000)
This matches the documentation, and passes the test suite when multithreading
is disabled.

Lib/compileall.py
Misc/NEWS

index 0cc0c1d530e03a64ad50ebbb89c54251759c14d3..2d4c523b4fef574d17c593a08fc9f2af11692d90 100644 (file)
@@ -66,13 +66,13 @@ def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None,
     optimize:  optimization level or -1 for level of the interpreter
     workers:   maximum number of parallel workers
     """
+    if workers is not None and workers < 0:
+        raise ValueError('workers must be greater or equal to 0')
+
     files = _walk_dir(dir, quiet=quiet, maxlevels=maxlevels,
                       ddir=ddir)
     success = 1
     if workers is not None and workers != 1 and ProcessPoolExecutor is not None:
-        if workers < 0:
-            raise ValueError('workers must be greater or equal to 0')
-
         workers = workers or None
         with ProcessPoolExecutor(max_workers=workers) as executor:
             results = executor.map(partial(compile_file,
index 3e2b34f41c2855bdeeea780dc3b2105d887a6560..c66a5217d2322ede95df0b2593851bb95e536d6d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -113,6 +113,10 @@ Core and Builtins
 Library
 -------
 
+- Issue #28485: Always raise ValueError for negative
+  compileall.compile_dir(workers=...) parameter, even when multithreading is
+  unavailable.
+
 - Issue #28387: Fixed possible crash in _io.TextIOWrapper deallocator when
   the garbage collector is invoked in other thread.  Based on patch by
   Sebastian Cufre.