Skip to content

bpo-44532: fix _PyStructSequence_InitType_Check #26949

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

Closed
wants to merge 1 commit into from
Closed

bpo-44532: fix _PyStructSequence_InitType_Check #26949

wants to merge 1 commit into from

Conversation

JunyiXie
Copy link
Contributor

@JunyiXie JunyiXie commented Jun 29, 2021

In _PyStructSequence_InitType, it will check type is initialized.
but when we have multi subinterpreters, type may be initialized in expected.

when type already been initialized, should return 0 rather than throw exception.

/* PyTypeObject has already been initialized */
if (Py_REFCNT(type) != 0) {
    return 0;
}
int
_PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc,
                           unsigned long tp_flags)
{
    PyMemberDef *members;
    Py_ssize_t n_members, n_unnamed_members;

#ifdef Py_TRACE_REFS
    /* if the type object was chained, unchain it first
       before overwriting its storage */
    if (type->ob_base.ob_base._ob_next) {
        _Py_ForgetReference((PyObject *)type);
    }
#endif

    /* PyTypeObject has already been initialized */
    if (Py_REFCNT(type) != 0) {
        PyErr_BadInternalCall();
        return -1;
    }

https://bugs.python.org/issue44532

@JunyiXie
Copy link
Contributor Author

@bedevere-bot skip news

@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 31, 2021
Copy link
Contributor

@MaxwellDupre MaxwellDupre left a comment

Choose a reason for hiding this comment

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

407 tests OK.
Looks fine to me.

@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants