mirror of https://github.com/python/cpython
[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:
parent
9f0269d6ae
commit
e54a28bcc9
|
@ -107,14 +107,14 @@ def check(file):
|
||||||
errprint("%r: Token Error: %s" % (file, msg))
|
errprint("%r: Token Error: %s" % (file, msg))
|
||||||
return
|
return
|
||||||
|
|
||||||
except SyntaxError as msg:
|
|
||||||
errprint("%r: Token Error: %s" % (file, msg))
|
|
||||||
return
|
|
||||||
|
|
||||||
except IndentationError as msg:
|
except IndentationError as msg:
|
||||||
errprint("%r: Indentation Error: %s" % (file, msg))
|
errprint("%r: Indentation Error: %s" % (file, msg))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
except SyntaxError as msg:
|
||||||
|
errprint("%r: Syntax Error: %s" % (file, msg))
|
||||||
|
return
|
||||||
|
|
||||||
except NannyNag as nag:
|
except NannyNag as nag:
|
||||||
badline = nag.get_lineno()
|
badline = nag.get_lineno()
|
||||||
line = nag.get_line()
|
line = nag.get_line()
|
||||||
|
|
|
@ -315,7 +315,7 @@ class TestCommandLine(TestCase):
|
||||||
def test_with_errored_file(self):
|
def test_with_errored_file(self):
|
||||||
"""Should displays error when errored python file is given."""
|
"""Should displays error when errored python file is given."""
|
||||||
with TemporaryPyFile(SOURCE_CODES["wrong_indented"]) as file_path:
|
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'
|
stderr += ('unindent does not match any outer indentation level'
|
||||||
' (<string>, line 3)')
|
' (<string>, line 3)')
|
||||||
self.validate_cmd(file_path, stderr=stderr, expect_failure=True)
|
self.validate_cmd(file_path, stderr=stderr, expect_failure=True)
|
||||||
|
|
|
@ -1096,6 +1096,7 @@ Ivan Levkivskyi
|
||||||
Ben Lewis
|
Ben Lewis
|
||||||
William Lewis
|
William Lewis
|
||||||
Akira Li
|
Akira Li
|
||||||
|
Jiahao Li
|
||||||
Robert Li
|
Robert Li
|
||||||
Xuanji Li
|
Xuanji Li
|
||||||
Zekun Li
|
Zekun Li
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix incorrect exception handling in Tab Nanny. Patch by Wulian233.
|
Loading…
Reference in New Issue