From cdb21ba74d933e262bc1696b6ce78b50cb5a4443 Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Tue, 14 Mar 2023 14:01:35 -0600 Subject: gh-102660: Handle m_copy Specially for the sys and builtins Modules (gh-102661) It doesn't make sense to use multi-phase init for these modules. Using a per-interpreter "m_copy" (instead of PyModuleDef.m_base.m_copy) makes this work okay. (This came up while working on gh-101660.) Note that we might instead end up disallowing re-load for sys/builtins since they are so special. https://github.com/python/cpython/issues/102660 --- Python/bltinmodule.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Python/bltinmodule.c') diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 12ca0ba6c48..a8a34620b9b 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -3098,6 +3098,9 @@ _PyBuiltin_Init(PyInterpreterState *interp) } Py_DECREF(debug); + /* m_copy of Py_None means it is copied some other way. */ + builtinsmodule.m_base.m_copy = Py_NewRef(Py_None); + return mod; #undef ADD_TO_ALL #undef SETBUILTIN -- cgit v1.2.3