Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-132775: Add _PyCode_VerifyStateless()#133221
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
gh-132775: Add _PyCode_VerifyStateless()#133221
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
!buildbot s390x RHEL8 LTO + PGO |
bedevere-bot commentedMay 5, 2025
🤖 New build scheduled with the buildbot fleet by@ericsnowcurrently for commitd45c0e0 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F133221%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
// The last instruction either returns or raises. We can take advantage | ||
// of that for a quick exit. | ||
_Py_CODEUNIT final = _Py_GetBaseCodeUnit(co, len-1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Is the warning on Windows fixable on this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
fixed
d270bb5
intopython:mainUh oh!
There was an error while loading.Please reload this page.
nascheme commentedMay 6, 2025 • edited by hugovk
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by hugovk
Uh oh!
There was an error while loading.Please reload this page.
This looks to be failing on the iOS buildbot. test_code (test)Doctest:test.test_code ... ok======================================================================ERROR:test_stateless (test.test_code.CodeTest.test_stateless) [(<function spam_N at 0x10fab5b50>, '(code)')]----------------------------------------------------------------------Traceback (most recent call last): File"/Users/buildbot/Library/Developer/XCTestDevices/3749308D-3FDE-41E4-B27C-3A4DD1FCF87A/data/Containers/Bundle/Application/40457EBF-BF74-4E58-B5DB-F52F8BC085A9/iOSTestbed.app/python/lib/python3.14/test/test_code.py", line1049, intest_stateless _testinternalcapi.verify_stateless_code(func.__code__)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^ValueError:only basic code objects are supported======================================================================ERROR:test_stateless (test.test_code.CodeTest.test_stateless) [(<function spam_C at 0x10fab4a10>, '(code)')]----------------------------------------------------------------------Traceback (most recent call last): File"/Users/buildbot/Library/Developer/XCTestDevices/3749308D-3FDE-41E4-B27C-3A4DD1FCF87A/data/Containers/Bundle/Application/40457EBF-BF74-4E58-B5DB-F52F8BC085A9/iOSTestbed.app/python/lib/python3.14/test/test_code.py", line1049, intest_stateless _testinternalcapi.verify_stateless_code(func.__code__)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^ValueError:only basic code objects are supported |
The test fails when it's run twice:
|
encukou commentedMay 6, 2025 • edited by hugovk
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by hugovk
Uh oh!
There was an error while loading.Please reload this page.
Looks like setting importsysimport_testinternalcapideffoo():passdeftrace_temporarily():sys._getframe().f_trace_opcodes=Truesys.settrace(print)sys.settrace(None)sys._getframe().f_trace_opcodes=Falsetrace_temporarily()_testinternalcapi.verify_stateless_code(foo.__code__)foo()_testinternalcapi.verify_stateless_code(foo.__code__)# fails In this case, |
I'm not sure what exactly "statelessness" is used for in the subinterpreters code. But, it looks like if it is to be useful, it either
Unfortunately, given the timing, I think this needs to be reverted for 3.14 :( |
@encukou Please could you open a revert PR? |
Will do. Resolving conflicts. |
…)"This reverts commitd270bb5.Note that the test functions in _code_definitions are not reverted.
Reverted in#133497. |
Thanks for jumping on this. I'll sort it out. FYI, the relevant code is |
…tateless() (pythongh-133221)" (python#133497)"This reverts commit3c73cf5.
Uh oh!
There was an error while loading.Please reload this page.
"Stateless" code is a function or code object which does not rely on external state or internal state. It may rely on arguments and
builtins, but not globals or a closure. I've left a comment in pycore_code.h that provides more detail.
We also add
_PyFunction_VerifyStateless()
. The new functions will be used in several later changes that facilitate "sharing" functions and code objects between interpreters.