Skip to content

Commit 84d2bbb

Browse files
committed
Workaround for 3to2 never returning non-zero when using the -j option.
1 parent d33e801 commit 84d2bbb

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎setup.py‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,16 @@ def run_3to2(args=None):
362362
"""
363363
args = BASE_ARGS_3TO2 if args is None else BASE_ARGS_3TO2 + args
364364
try:
365-
return subprocess.call(["3to2"] + args)
365+
# HACK: workaround for 3to2 never returning non-zero
366+
# when using the -j option.
367+
proc = subprocess.Popen(["3to2"] + args, stderr=subprocess.PIPE)
368+
num_errors = 0
369+
while proc.poll() is None:
370+
line = proc.stderr.readline()
371+
sys.stderr.write(line)
372+
num_errors += line.count(": ParseError: ")
373+
if proc.returncode or num_errors:
374+
raise Exception("lib3to2 parsing error")
366375
except OSError:
367376
for path in glob.glob("*.egg"):
368377
if os.path.isdir(path) and not path in sys.path:
@@ -372,7 +381,8 @@ def run_3to2(args=None):
372381
except ImportError:
373382
raise OSError("3to2 script is unavailable.")
374383
else:
375-
return lib3to2_main("lib3to2.fixes", args)
384+
if lib3to2_main("lib3to2.fixes", args):
385+
raise Exception("lib3to2 parsing error")
376386

377387

378388
def write_py2k_header(file_list):

0 commit comments

Comments
 (0)