diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-06-15 11:28:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-15 11:28:28 (GMT) |
commit | e54a28bcc9114f296bd1d63010eedbd0c2140d71 (patch) | |
tree | 8f8dcb3e557088c4e03fe2964264659a39eb14fd | |
parent | 9f0269d6aed1b61996b95dc0730a4008de012011 (diff) | |
download | cpython-e54a28bcc9114f296bd1d63010eedbd0c2140d71.zip cpython-e54a28bcc9114f296bd1d63010eedbd0c2140d71.tar.gz cpython-e54a28bcc9114f296bd1d63010eedbd0c2140d71.tar.bz2 |
[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 c501261c919ceb97c850ef9427a93326f06a8f2e)
Co-authored-by: Wulian233 <71213467+Wulian233@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
-rwxr-xr-x | Lib/tabnanny.py | 8 | ||||
-rw-r--r-- | Lib/test/test_tabnanny.py | 2 | ||||
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2024-06-14-20-05-25.gh-issue-120495.OxgZKB.rst | 1 |
4 files changed, 7 insertions, 5 deletions
diff --git a/Lib/tabnanny.py b/Lib/tabnanny.py index e2ac683..d06c4c2 100755 --- a/Lib/tabnanny.py +++ b/Lib/tabnanny.py @@ -107,14 +107,14 @@ def check(file): errprint("%r: Token Error: %s" % (file, msg)) return - except SyntaxError as msg: - errprint("%r: Token Error: %s" % (file, msg)) - return - except IndentationError as msg: errprint("%r: Indentation Error: %s" % (file, msg)) return + except SyntaxError as msg: + errprint("%r: Syntax Error: %s" % (file, msg)) + return + except NannyNag as nag: badline = nag.get_lineno() line = nag.get_line() diff --git a/Lib/test/test_tabnanny.py b/Lib/test/test_tabnanny.py index cc122ca..30dcb3e 100644 --- a/Lib/test/test_tabnanny.py +++ b/Lib/test/test_tabnanny.py @@ -315,7 +315,7 @@ class TestCommandLine(TestCase): def test_with_errored_file(self): """Should displays error when errored python file is given.""" 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' ' (<string>, line 3)') self.validate_cmd(file_path, stderr=stderr, expect_failure=True) @@ -1096,6 +1096,7 @@ Ivan Levkivskyi Ben Lewis William Lewis Akira Li +Jiahao Li Robert Li Xuanji Li Zekun Li diff --git a/Misc/NEWS.d/next/Library/2024-06-14-20-05-25.gh-issue-120495.OxgZKB.rst b/Misc/NEWS.d/next/Library/2024-06-14-20-05-25.gh-issue-120495.OxgZKB.rst new file mode 100644 index 0000000..d5114c3 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-06-14-20-05-25.gh-issue-120495.OxgZKB.rst @@ -0,0 +1 @@ +Fix incorrect exception handling in Tab Nanny. Patch by Wulian233. |