Skip to content

Commit

Permalink
pythongh-120495: Fix incorrect exception handling in Tab Nanny (pytho…
Browse files Browse the repository at this point in the history
…nGH-120498)

(cherry picked from commit c501261)

Co-authored-by: Wulian233 <71213467+Wulian233@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
  • Loading branch information
2 people authored and miss-islington committed Jun 15, 2024
1 parent 9f0269d commit b93b9cb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Lib/tabnanny.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ def check(file):
errprint("%r: Token Error: %s" % (file, msg))
return

except SyntaxError as msg:
errprint("%r: Token Error: %s" % (file, msg))
return

except IndentationError as msg:
errprint("%r: Indentation Error: %s" % (file, msg))
return

except SyntaxError as msg:
errprint("%r: Syntax Error: %s" % (file, msg))
return

except NannyNag as nag:
badline = nag.get_lineno()
line = nag.get_line()
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_tabnanny.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def validate_cmd(self, *args, stdout="", stderr="", partial=False, expect_failur
def test_with_errored_file(self):
"""Should displays error when errored python file is given."""
with TemporaryPyFile(SOURCE_CODES["wrong_indented"]) as file_path:
stderr = f"{file_path!r}: Token Error: "
stderr = f"{file_path!r}: Indentation Error: "
stderr += ('unindent does not match any outer indentation level'
' (<string>, line 3)')
self.validate_cmd(file_path, stderr=stderr, expect_failure=True)
Expand Down
1 change: 1 addition & 0 deletions Misc/ACKS
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,7 @@ Ivan Levkivskyi
Ben Lewis
William Lewis
Akira Li
Jiahao Li
Robert Li
Xuanji Li
Zekun Li
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix incorrect exception handling in Tab Nanny. Patch by Wulian233.

0 comments on commit b93b9cb

Please sign in to comment.