Skip to content

Python: Stop using global static state in C extension #10143

@cretz

Description

@cretz

What language does this apply to?

Python

Describe the problem you are trying to solve.

Would like to be able to use the Python extension in subinterpreters or after reload.

Because of the assignment at

PythonMessage_class = PyObject_GetAttrString(message_module, "Message");
to the C-static variable, the
PyErr_SetString(PyExc_TypeError,
"A Message class can only inherit from Message");
error is triggered in subinterpreters or when reloading the module. This is because the message class may not be the same in a subinterpreter/reload as it was when the module was first loaded.

Describe the solution you'd like

Options:

  1. See PEP 3121. Start using module state instead of C-static state so it can be safely reloaded.
  2. Stop checking for module class extension using static state

Metadata

Metadata

Assignees

No one assigned

    Labels

    inactiveDenotes the issue/PR has not seen activity in the last 90 days.python

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions