8000 [3.12] gh-120495: Fix incorrect exception handling in Tab Nanny (GH-1… · python/cpython@1242c27 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1242c27

Browse files
miss-islingtonWulian233hugovk
authored
[3.12] gh-120495: Fix incorrect exception handling in Tab Nanny (GH-120498) (#120549)
gh-120495: Fix incorrect exception handling in Tab Nanny (GH-120498) (cherry picked from commit c501261) Co-authored-by: Wulian233 <71213467+Wulian233@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent 92c1687 commit 1242c27

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
@@ -1086,6 +1086,7 @@ Ivan Levkivskyi
10861086
Ben Lewis
10871087
William Lewis
10881088
Akira Li
1089+
Jiahao Li
10891090
Robert Li
10901091
Xuanji Li
10911092
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)
0