Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-120495: Fix incorrect exception handling in Tab Nanny #120498

Merged
merged 5 commits into from
Jun 15, 2024

Conversation

Wulian233
Copy link
Contributor

@Wulian233 Wulian233 commented Jun 14, 2024

See issue, need backport to 3.13?

2024-06-14 195123

Lib/tabnanny.py Outdated Show resolved Hide resolved
Wulian233 and others added 2 commits June 14, 2024 20:15
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
@hugovk hugovk changed the title gh-120495: Fix incorrect Exception Handling in tabnanny gh-120495: Fix incorrect exception handling in Tab Nanny Jun 14, 2024
@hugovk
Copy link
Member

hugovk commented Jun 14, 2024

Please check the test failure:

======================================================================
FAIL: test_with_errored_file (test.test_tabnanny.TestCommandLine.test_with_errored_file)
Should displays error when errored python file is given.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/admin/actions-runner/_work/cpython/cpython/Lib/test/test_tabnanny.py", line 321, in test_with_errored_file
    self.validate_cmd(file_path, stderr=stderr, expect_failure=True)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/admin/actions-runner/_work/cpython/cpython/Lib/test/test_tabnanny.py", line 313, in validate_cmd
    self.assertListEqual(err.splitlines(), stderr.splitlines())
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Lists differ: ["'/v[80 chars]py': Indentation Error: unindent does not matc[45 chars] 3)"] != ["'/v[80 chars]py': Token Error: unindent does not match any [39 chars] 3)"]

First differing element 0:
"'/va[79 chars]py': Indentation Error: unindent does not matc[44 chars]e 3)"
"'/va[79 chars]py': Token Error: unindent does not match any [38 chars]e 3)"

  ["'/var/folders/4_/xyjwmyz[149](https://github.com/python/cpython/actions/runs/9515941863/job/26231269530?pr=120498#step:9:150)7g3qhhndg003800000gn/T/test_python_1c7vs70o/tmpubu1lray.py': "
-  'Indentation Error: unindent does not match any outer indentation level '
?   ^^^  ------

+  'Token Error: unindent does not match any outer indentation level (<string>, '
?   ^^^                                                              +++++++++++

-  '(<string>, line 3)']
+  'line 3)']

@hugovk
Copy link
Member

hugovk commented Jun 14, 2024

Before, the indentation test test_with_errored_file hit the first block:

    except SyntaxError as msg:
        errprint("%r: Token Error: %s" % (file, msg))
        return

But now, it's hitting the correct one:

    except IndentationError as msg:
        errprint("%r: Indentation Error: %s" % (file, msg))
        return

So we need to fix the test to look for the correct "Indentation Error" text.

Please could you update the test?

@Wulian233
Copy link
Contributor Author

@hugovk
Copy link
Member

hugovk commented Jun 14, 2024

That's right, change "Token Error" to "Indentation Error" :)

Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@hugovk hugovk added needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes labels Jun 15, 2024
@hugovk hugovk enabled auto-merge (squash) June 15, 2024 11:04
@hugovk hugovk merged commit c501261 into python:main Jun 15, 2024
37 checks passed
@miss-islington-app
Copy link

Thanks @Wulian233 for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 15, 2024
…nGH-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>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 15, 2024
…nGH-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>
@bedevere-app
Copy link

bedevere-app bot commented Jun 15, 2024

GH-120548 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jun 15, 2024
@bedevere-app
Copy link

bedevere-app bot commented Jun 15, 2024

GH-120549 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Jun 15, 2024
hugovk added a commit that referenced this pull request Jun 15, 2024
…20498) (#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>
hugovk added a commit that referenced this pull request Jun 15, 2024
…20498) (#120548)

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>
@Wulian233 Wulian233 deleted the tabnanny branch June 19, 2024 10:16
mrahtz pushed a commit to mrahtz/cpython that referenced this pull request Jun 30, 2024
…n#120498)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
…n#120498)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
…n#120498)

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants