[3.13] gh-120495: Fix incorrect exception handling in Tab Nanny (GH-120498) (#120548)

gh-120495: Fix incorrect exception handling in Tab Nanny (GH-120498)
(cherry picked from commit c501261c91)

Co-authored-by: Wulian233 <71213467+Wulian233@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2024-06-15 13:28:28 +02:00 committed by GitHub
parent 9f0269d6ae
commit e54a28bcc9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 5 deletions

View File

@ -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()

View File

@ -315,7 +315,7 @@ class TestCommandLine(TestCase):
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)

View File

@ -1096,6 +1096,7 @@ Ivan Levkivskyi
Ben Lewis
William Lewis
Akira Li
Jiahao Li
Robert Li
Xuanji Li
Zekun Li

View File

@ -0,0 +1 @@
Fix incorrect exception handling in Tab Nanny. Patch by Wulian233.