You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ensure PyEval_GetGlobals() doesn't set an exception when returning NULL #91360
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/ncoghlan'closed_at=Nonecreated_at=<Date2022-04-03.06:41:46.197>labels= ['type-feature']
title="Ensure PyEval_GetGlobals() doesn't set an exception when returning NULL"updated_at=<Date2022-04-03.06:48:44.524>user='https://github.com/ncoghlan'
While working on the first PR for bpo-44800 I provoked an obscure failure in PyImport_ImportModule by making PyEval_GetGlobals set an exception when returning NULL (as PyEval_GetLocals has done since bpo-18408 was implemented for Python 3.4).
This ticket covers adding an embedding test case that:
ensures PyEval_GetGlobals() returns NULL without an exception when no Python frame is active
ensures PyEval_GetLocals() returns NULL and sets an exception when no Python frame is active
ensures PyImport_ImportModule still works when no Python frame is active
There's an option to slightly change the behaviour of PyEval_GetLocals() to NOT set an exception in the "no Python frame" case, and instead only set the error when there is a Python frame, but something goes wrong when attempting to access the fast locals array (such as a memory allocation failure).
Activity
ncoghlan commentedon Apr 3, 2022
While working on the first PR for bpo-44800 I provoked an obscure failure in PyImport_ImportModule by making PyEval_GetGlobals set an exception when returning NULL (as PyEval_GetLocals has done since bpo-18408 was implemented for Python 3.4).
This ticket covers adding an embedding test case that:
There's an option to slightly change the behaviour of
PyEval_GetLocals()to NOT set an exception in the "no Python frame" case, and instead only set the error when there is a Python frame, but something goes wrong when attempting to access the fast locals array (such as a memory allocation failure).ncoghlan commentedon Apr 3, 2022
Core dev forum thread for the C API question: https://discuss.python.org/t/subtle-c-api-discrepancy-pyeval-getlocals-vs-pyeval-getglobals-with-no-python-frame/14797