Skip to content

Commit

Permalink
feat: display concrete SyntaxError (#60)
Browse files Browse the repository at this point in the history
otherwise only the filename is shown but not the concrete line number.
  • Loading branch information
spaceone authored Mar 14, 2024
1 parent 40516f2 commit 8803fad
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/com2ann.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,8 @@ def com2ann(code: str, *,
tree = ast.parse(code,
type_comments=True,
feature_version=(3, python_minor_version))
except SyntaxError:
except SyntaxError as exc:
print("SyntaxError:", exc, file=sys.stderr)
return None
lines = code.splitlines(keepends=True)
rl = BytesIO(code.encode('utf-8')).readline
Expand Down

0 comments on commit 8803fad

Please sign in to comment.