Report failure to parse files when running 2to3

This commit is contained in:
Kovid Goyal 2019-05-15 21:19:02 +05:30
parent f51e63718c
commit 7a4f44b6aa
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -86,9 +86,11 @@ class To3(Command):
oo, oe = sys.stdout, sys.stderr
sys.stdout = sys.stderr = buf = PolyglotStringIO()
try:
run_2to3(f)
ret = run_2to3(f)
finally:
sys.stdout, sys.stderr = oo, oe
if ret:
raise SystemExit('Could not parse: ' + f)
output = buf.getvalue()
return re.search(r'^RefactoringTool: No changes to ' + f, output, flags=re.M) is None