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

Ensure PyEval_GetGlobals() doesn't set an exception when returning NULL #91360

Open
ncoghlan opened this issue Apr 3, 2022 · 2 comments
Open
Assignees
Labels
extension-modules C modules in the Modules dir interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-C-API type-feature A feature request or enhancement

Comments

@ncoghlan
Copy link
Contributor

ncoghlan commented Apr 3, 2022

BPO 47204
Nosy @ncoghlan

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 = None
created_at = <Date 2022-04-03.06:41:46.197>
labels = ['type-feature']
title = "Ensure PyEval_GetGlobals() doesn't set an exception when returning NULL"
updated_at = <Date 2022-04-03.06:48:44.524>
user = 'https://github.com/ncoghlan'

bugs.python.org fields:

activity = <Date 2022-04-03.06:48:44.524>
actor = 'ncoghlan'
assignee = 'ncoghlan'
closed = False
closed_date = None
closer = None
components = []
creation = <Date 2022-04-03.06:41:46.197>
creator = 'ncoghlan'
dependencies = []
files = []
hgrepos = []
issue_num = 47204
keywords = []
message_count = 2.0
messages = ['416611', '416612']
nosy_count = 1.0
nosy_names = ['ncoghlan']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'test needed'
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue47204'
versions = []

@ncoghlan
Copy link
Contributor Author

ncoghlan commented 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:

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

@ncoghlan ncoghlan added type-feature A feature request or enhancement labels Apr 3, 2022
@ncoghlan
Copy link
Contributor Author

ncoghlan commented Apr 3, 2022

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@iritkatriel iritkatriel added interpreter-core (Objects, Python, Grammar, and Parser dirs) extension-modules C modules in the Modules dir labels Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-C-API type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants