Consider the following minimal example C code which is trying to import jsonschema (https://python-jsonschema.readthedocs.io/en/stable/), compiled using "gcc test_newinterpreter.c -I /usr/include/python3.10 -lpython3.10 -o test_newinterpreter" or similar:
#include <Python.h>
int main(void) {
Py_Initialize();
PyThreadState *interpreter = Py_NewInterpreter();
PyRun_SimpleString("import jsonschema");
Py_Finalize();
}
In Python 3.9.9, this works as expected. However in Python 3.10.0, the following error is produced:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.10/site-packages/jsonschema/__init__.py", line 21, in <module>
from jsonschema._types import TypeChecker
File "/usr/lib/python3.10/site-packages/jsonschema/_types.py", line 168, in <module>
draft3_type_checker = TypeChecker(
TypeError: TypeChecker() takes no arguments
Removing the Py_NewInterpreter() call makes the example work as expected in Python 3.10.0.
This might be related to the enhancements to the type cache from bpo-42745.
Another recent bug report I found that might possibly be related is bpo-46036.
This bug breaks some WeeChat plugins that try to import one of the affected modules, e.g. weechat-matrix (https://github.com/poljar/weechat-matrix).
|