Skip to content

Commit e54a28b

Browse files
miss-islingtonWulian233hugovk
authored
[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 c501261) Co-authored-by: Wulian233 <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 9f0269d commit e54a28b

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
@@ -107,14 +107,14 @@ def check(file):
107107
errprint("%r: Token Error: %s" % (file, msg))
108108
return
109109

110-
except SyntaxError as msg:
111-
errprint("%r: Token Error: %s" % (file, msg))
112-
return
113-
114110
except IndentationError as msg:
115111
errprint("%r: Indentation Error: %s" % (file, msg))
116112
return
117113

114+
except SyntaxError as msg:
115+
errprint("%r: Syntax Error: %s" % (file, msg))
116+
return
117+
118118
except NannyNag as nag:
119119
badline = nag.get_lineno()
120120
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
@@ -1096,6 +1096,7 @@ Ivan Levkivskyi
10961096
Ben Lewis
10971097
William Lewis
10981098
Akira Li
1099+
Jiahao Li
10991100
Robert Li
11001101
Xuanji Li
11011102
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)