gh-120495: Fix incorrect exception handling in Tab Nanny (#120498)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
@@ -105,14 +105,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)
|
||||||
|
|||||||
@@ -1099,6 +1099,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.
|
||||||
Reference in New Issue
Block a user