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
…n#120498)

Co-authored-by: Hugo van Kemenade <[email protected]>
  • Loading branch information
Wulian233 and hugovk authored Jun 15, 2024
1 parent 42ebdd8 commit c501261
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 @@ -105,14 +105,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 @@ -1099,6 +1099,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 c501261

Please sign in to comment.