This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: When using Py_NewInterpreter, some modules fail to import in Python 3.10
Type: compile error Stage: resolved
Components: C API, Subinterpreters Versions: Python 3.10
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: diabonas
Priority: normal Keywords:

Created on 2021-12-11 12:12 by diabonas, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg408295 - (view) Author: Jonas Witschel (diabonas) Date: 2021-12-11 12:12
Consider the following minimal example C code which is trying to import jsonschema (, compiled using "gcc test_newinterpreter.c -I /usr/include/python3.10 -lpython3.10 -o test_newinterpreter" or similar:

#include <Python.h>

int main(void) {
	PyThreadState *interpreter = Py_NewInterpreter();
	PyRun_SimpleString("import jsonschema");

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/", line 21, in <module>
    from jsonschema._types import TypeChecker
  File "/usr/lib/python3.10/site-packages/jsonschema/", 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 (
msg408297 - (view) Author: Jonas Witschel (diabonas) Date: 2021-12-11 12:26
Downstream bug report in Arch Linux:
msg408299 - (view) Author: Jonas Witschel (diabonas) Date: 2021-12-11 13:05
I notice this has already been reported as bpo-46006 and bpo-46034, so closing in favour of these.
Date User Action Args
2022-04-11 14:59:53adminsetgithub: 90205
2021-12-11 13:05:13diabonassetstatus: open -> closed
resolution: duplicate
messages: + msg408299

stage: resolved
2021-12-11 12:26:32diabonassetmessages: + msg408297
2021-12-11 12:12:05diabonascreate