Skip to content

gh-75646: allow _PyType_Lookup() to raise exceptions #3616

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

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

scoder
Copy link
Contributor

@scoder scoder commented Sep 16, 2017

This is based off #3279, the first commits are the same, because they touch the same code. FIrst new commit is 6c61028, right after the merge of "master". 6c61028 is a related bug fix, an unchecked error case.

Probably needs new tests that exercise the error conditions.

https://bugs.python.org/issue31465

Stefan Behnel added 23 commits September 4, 2017 13:27
…r ceases to be a valid base type, there'll probably be larger code sections to change than this one.
…common in Python 3 now.

Also make the step from "return NULL" error handling to "goto error" reference cleanup explicit.
Distinguish between "error" and "error with exception" cases in _PyType_LookupUncached().
Fix a reference leak of "mro" on lookup errors.
Resolves issues found by Serhiy Storchaka.
…isting) API names.

Suggested by Serhiy Storchaka.
…e-calculation if the mapping is not exactly a dict.
…ential re-calculation if the mapping is not exactly a dict."

This reverts commit 1d52082.
… and call PyObject_GetItem() for them."

This reverts commit 09e716a.
…g lookup exceptions, just like "_PyType_Lookup()" did previously.
…ce eating lookup exceptions, just like "_PyType_Lookup()" did previously."

This reverts commit 4efde8e.
…) from functions that swallow live exceptions.
… handle them in the code that calls these functions.

The one non-exception error case during lookup ("no MRO") is not handled since it is unlikely and not user visible.
Note that this changes the signature of both functions, but they are clearly not public functions.
Currently leads to crashes due to NULL returns without exceptions set. Needs investigation.
@markshannon
Copy link
Member

Two minor points.
I would prefer a new function, rather than modifying the signature of _PyType_Lookup.
Also, I think it is the conventional to return error codes directly and objects via the pointer, not the other way around. So int _PyType_Lookup(type, name, *result) not PyObject *_PyType_Lookup(type, name, *error)

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Feb 22, 2022
MaxwellDupre

This comment was marked as outdated.

@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Jul 29, 2022
@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Aug 31, 2022
Copy link
Member

@iritkatriel iritkatriel left a comment

Choose a reason for hiding this comment

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

This has merge conflicts now.

@bedevere-bot
Copy link

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

And if you don't make the requested changes, you will be put in the comfy chair!

@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Nov 26, 2022
@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Dec 26, 2022
@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Feb 23, 2023
@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Mar 26, 2023
@furkanonder
Copy link
Contributor

@scoder Could you resolve the conflicts?

@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label May 12, 2023
@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Jun 11, 2023
@erlend-aasland erlend-aasland changed the title bpo-31465: allow _PyType_Lookup() to raise exceptions gh-75646: allow _PyType_Lookup() to raise exceptions Jun 14, 2023
@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Jun 15, 2023
@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting changes stale Stale PR or inactive for long period of time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants