From a86ed80af15ffa230ce029ee4d8468358da74bd2 Mon Sep 17 00:00:00 2001 From: Wulian233 <1055917385@qq.com> Date: Fri, 14 Jun 2024 20:09:00 +0800 Subject: [PATCH 1/5] Fix incorrect Exception Handling in tabnanny --- Lib/tabnanny.py | 8 ++++---- .../2024-06-14-20-05-25.gh-issue-120495.OxgZKB.rst | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2024-06-14-20-05-25.gh-issue-120495.OxgZKB.rst diff --git a/Lib/tabnanny.py b/Lib/tabnanny.py index 7e56d4a48d1d00..a9a3b63a3a0b5a 100644 --- a/Lib/tabnanny.py +++ b/Lib/tabnanny.py @@ -105,14 +105,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: Token Error: %s" % (file, msg)) + return + except NannyNag as nag: badline = nag.get_lineno() line = nag.get_line() 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 00000000000000..9f0c3377341634 --- /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 tabnanny. Patch by Wulian233 From 898126c560237b91c2b4f5c8cffc509ac8fa87c6 Mon Sep 17 00:00:00 2001 From: Wulian233 <71213467+Wulian233@users.noreply.github.com> Date: Fri, 14 Jun 2024 20:15:22 +0800 Subject: [PATCH 2/5] a copy paste error Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- Lib/tabnanny.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/tabnanny.py b/Lib/tabnanny.py index a9a3b63a3a0b5a..c0097351b269f2 100644 --- a/Lib/tabnanny.py +++ b/Lib/tabnanny.py @@ -110,7 +110,7 @@ def check(file): return except SyntaxError as msg: - errprint("%r: Token Error: %s" % (file, msg)) + errprint("%r: Syntax Error: %s" % (file, msg)) return except NannyNag as nag: From 84cc45acd41c59b641be8e11ad8b12fd5c1a1505 Mon Sep 17 00:00:00 2001 From: Wulian233 <71213467+Wulian233@users.noreply.github.com> Date: Fri, 14 Jun 2024 20:15:44 +0800 Subject: [PATCH 3/5] news Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> --- .../next/Library/2024-06-14-20-05-25.gh-issue-120495.OxgZKB.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 9f0c3377341634..d5114c3d3c904c 100644 --- 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 @@ -1 +1 @@ -Fix incorrect Exception Handling in tabnanny. Patch by Wulian233 +Fix incorrect exception handling in Tab Nanny. Patch by Wulian233. From fa71a96ee7a264626dbdcb965ddc129717b7d20c Mon Sep 17 00:00:00 2001 From: Wulian233 <71213467+Wulian233@users.noreply.github.com> Date: Fri, 14 Jun 2024 20:30:49 +0800 Subject: [PATCH 4/5] ACKS --- Misc/ACKS | 1 + 1 file changed, 1 insertion(+) diff --git a/Misc/ACKS b/Misc/ACKS index 2f4c0793437fb6..a406fca8744a5f 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1099,6 +1099,7 @@ Ivan Levkivskyi Ben Lewis William Lewis Akira Li +Jiahao Li Robert Li Xuanji Li Zekun Li From 884b37a2aa81951af1fb035b452302effab2eb00 Mon Sep 17 00:00:00 2001 From: Wulian233 <71213467+Wulian233@users.noreply.github.com> Date: Sat, 15 Jun 2024 06:37:55 +0800 Subject: [PATCH 5/5] test_tabnanny --- Lib/test/test_tabnanny.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_tabnanny.py b/Lib/test/test_tabnanny.py index cc122cafc7985c..30dcb3e3c4f4f9 100644 --- a/Lib/test/test_tabnanny.py +++ b/Lib/test/test_tabnanny.py @@ -315,7 +315,7 @@ def validate_cmd(self, *args, stdout="", stderr="", partial=False, expect_failur 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' ' (, line 3)') self.validate_cmd(file_path, stderr=stderr, expect_failure=True)