Skip to content

Commit 88281ce

Browse files
committed
Issue python#28485: Check for negative workers even without ProcessPoolExecutor
This matches the documentation, and passes the test suite when multithreading is disabled.
1 parent da4887a commit 88281ce

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

Lib/compileall.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None,
6666
optimize: optimization level or -1 for level of the interpreter
6767
workers: maximum number of parallel workers
6868
"""
69+
if workers is not None and workers < 0:
70+
raise ValueError('workers must be greater or equal to 0')
71+
6972
files = _walk_dir(dir, quiet=quiet, maxlevels=maxlevels,
7073
ddir=ddir)
7174
success = 1
7275
if workers is not None and workers != 1 and ProcessPoolExecutor is not None:
73-
if workers < 0:
74-
raise ValueError('workers must be greater or equal to 0')
75-
7676
workers = workers or None
7777
with ProcessPoolExecutor(max_workers=workers) as executor:
7878
results = executor.map(partial(compile_file,

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ Core and Builtins
113113
Library
114114
-------
115115

116+
- Issue #28485: Always raise ValueError for negative
117+
compileall.compile_dir(workers=...) parameter, even when multithreading is
118+
unavailable.
119+
116120
- Issue #28387: Fixed possible crash in _io.TextIOWrapper deallocator when
117121
the garbage collector is invoked in other thread. Based on patch by
118122
Sebastian Cufre.

0 commit comments

Comments
 (0)