Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c501261

Browse files
Wulian233hugovk
andauthored
gh-120495: Fix incorrect exception handling in Tab Nanny (#120498)
Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 42ebdd8 commit c501261

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

Lib/tabnanny.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ def check(file):
105105
errprint("%r: Token Error: %s" % (file, msg))
106106
return
107107

108-
except SyntaxError as msg:
109-
errprint("%r: Token Error: %s" % (file, msg))
110-
return
111-
112108
except IndentationError as msg:
113109
errprint("%r: Indentation Error: %s" % (file, msg))
114110
return
115111

112+
except SyntaxError as msg:
113+
errprint("%r: Syntax Error: %s" % (file, msg))
114+
return
115+
116116
except NannyNag as nag:
117117
badline = nag.get_lineno()
118118
line = nag.get_line()

Lib/test/test_tabnanny.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def validate_cmd(self, *args, stdout="", stderr="", partial=False, expect_failur
315315
def test_with_errored_file(self):
316316
"""Should displays error when errored python file is given."""
317317
with TemporaryPyFile(SOURCE_CODES["wrong_indented"]) as file_path:
318-
stderr = f"{file_path!r}: Token Error: "
318+
stderr = f"{file_path!r}: Indentation Error: "
319319
stderr += ('unindent does not match any outer indentation level'
320320
' (<string>, line 3)')
321321
self.validate_cmd(file_path, stderr=stderr, expect_failure=True)

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,7 @@ Ivan Levkivskyi
10991099
Ben Lewis
11001100
William Lewis
11011101
Akira Li
1102+
Jiahao Li
11021103
Robert Li
11031104
Xuanji Li
11041105
Zekun Li
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix incorrect exception handling in Tab Nanny. Patch by Wulian233.

0 commit comments

Comments
 (0)