X Tutup
The Wayback Machine - https://web.archive.org/web/20221223181248/https://github.com/python/cpython/pull/92440
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-92031: Improve test for unquickening static code #92440

Merged
merged 3 commits into from May 11, 2022

Conversation

sweeneyde
Copy link
Member

@sweeneyde sweeneyde commented May 8, 2022

This test is deterministic, faster, and directly tests the behavior it's supposed to be testing, rather than relying on some C-level assertion to fail.

I checked that commenting out deopt_code(...) in _PyStaticCode_Dealloc causes the test to fail reliably.

cc @vstinner @markshannon

_handle_fromlist(dis, [name], lambda *args: None)
from dis import _all_opmap
resume = _all_opmap["RESUME"]
resume_quick = _all_opmap["RESUME_QUICK"]
Copy link
Member

@vstinner vstinner May 9, 2022

Choose a reason for hiding this comment

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

Why not putting this code inside the code string?

Copy link
Member Author

@sweeneyde sweeneyde May 10, 2022

Choose a reason for hiding this comment

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

Since this is testing parts of importlib, I'd like to use as little import machinery as possible, so there's no chance that imports prematurely specialize the _handle_fromlist.

Copy link
Member

@vstinner vstinner May 11, 2022

Choose a reason for hiding this comment

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

Maybe add a comment to explain it, since it's not obvious the first time that I read the code: the code starts with "Assert initially unquickened".

Lib/test/test_embed.py Outdated Show resolved Hide resolved
Lib/test/test_embed.py Outdated Show resolved Hide resolved
Lib/test/test_embed.py Outdated Show resolved Hide resolved
@vstinner vstinner merged commit 27185f9 into python:main May 11, 2022
12 checks passed
@miss-islington
Copy link
Contributor

miss-islington commented May 11, 2022

Thanks @sweeneyde for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11.
🐍🍒🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 11, 2022
…pythonGH-92440)

(cherry picked from commit 27185f9)

Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
@vstinner
Copy link
Member

vstinner commented May 11, 2022

Merged, thanks!

@bedevere-bot
Copy link

bedevere-bot commented May 11, 2022

GH-92699 is a backport of this pull request to the 3.11 branch.

miss-islington added a commit that referenced this pull request May 11, 2022
…2440)

(cherry picked from commit 27185f9)

Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
@sweeneyde sweeneyde deleted the better_test branch Jun 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants
X Tutup