[New-bugs-announce] [issue47204] Ensure PyEval_GetGlobals() doesn't set an exception when returning NULL

Nick Coghlan report at bugs.python.org
Sun Apr 3 02:41:46 EDT 2022


New submission from Nick Coghlan <ncoghlan at gmail.com>:

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).

----------
assignee: ncoghlan
messages: 416611
nosy: ncoghlan
priority: normal
severity: normal
stage: test needed
status: open
title: Ensure PyEval_GetGlobals() doesn't set an exception when returning NULL
type: enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47204>
_______________________________________


More information about the New-bugs-announce mailing list