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

bpo-43770: PyObject_SetAttr() asserts that the type is ready #26880

Closed
wants to merge 1 commit into from
Closed

bpo-43770: PyObject_SetAttr() asserts that the type is ready #26880

wants to merge 1 commit into from

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jun 23, 2021

PyObject_SetAttr() now ensures that the object type is ready with an
assertion. Moreover, it now only calls Py_DECREF(name) after raising
the TypeError, rather than using a borrowed reference.

https://bugs.python.org/issue43770

PyObject_SetAttr() now ensures that the object type is ready with an
assertion. Moreover, it now only calls Py_DECREF(name) after raising
the TypeError, rather than using a borrowed reference.
@vstinner
Copy link
Member Author

This change can be backward incompatible (for Python built in debug mode). Maybe an approach like PR #26881 is needed.

The default implementation of tp_setattro is PyObject_GenericSetAttr (PyBaseObject_Type.tp_setattro), and it does make the type ready if it is not:

    if (tp->tp_dict == NULL && PyType_Ready(tp) < 0)
        return -1;

https://bugs.python.org/issue43770 issue is when a static type uses tp_setattro=NULL and the PyObject_SetAttr() is called on a type which is not ready.

@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 Jul 24, 2021
@vstinner
Copy link
Member Author

I abandon this PR. I'm not convinced that it's safe.

@vstinner vstinner closed this Sep 21, 2021
@vstinner vstinner deleted the objet_setattr branch September 21, 2021 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review skip news stale Stale PR or inactive for long period of time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants