From 88281ceed02d8f4599cb22f196e40bc30f4fb689 Mon Sep 17 00:00:00 2001 From: Martin Panter Date: Sat, 5 Nov 2016 01:11:36 +0000 Subject: Issue #28485: Check for negative workers even without ProcessPoolExecutor This matches the documentation, and passes the test suite when multithreading is disabled. --- Lib/compileall.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Lib/compileall.py') diff --git a/Lib/compileall.py b/Lib/compileall.py index 0cc0c1d530..2d4c523b4f 100644 --- a/Lib/compileall.py +++ b/Lib/compileall.py @@ -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, -- cgit v1.2.1