0
0
mirror of https://github.com/python/cpython.git synced 2024-11-24 00:38:00 +01:00

gh-116322: Add Py_mod_gil module slot (#116882)

This PR adds the ability to enable the GIL if it was disabled at
interpreter startup, and modifies the multi-phase module initialization
path to enable the GIL when loading a module, unless that module's spec
includes a slot indicating it can run safely without the GIL.

PEP 703 called the constant for the slot `Py_mod_gil_not_used`; I went
with `Py_MOD_GIL_NOT_USED` for consistency with gh-104148.

A warning will be issued up to once per interpreter for the first
GIL-using module that is loaded. If `-v` is given, a shorter message
will be printed to stderr every time a GIL-using module is loaded
(including the first one that issues a warning).
This commit is contained in:
Brett Simmers 2024-05-03 08:30:55 -07:00 committed by GitHub
parent 3e818afb9b
commit c2627d6eea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
123 changed files with 376 additions and 62 deletions

View File

@ -411,6 +411,31 @@ The available slot types are:
.. versionadded:: 3.12
.. c:macro:: Py_mod_gil
Specifies one of the following values:
.. c:macro:: Py_MOD_GIL_USED
The module depends on the presence of the global interpreter lock (GIL),
and may access global state without synchronization.
.. c:macro:: Py_MOD_GIL_NOT_USED
The module is safe to run without an active GIL.
This slot is ignored by Python builds not configured with
:option:`--disable-gil`. Otherwise, it determines whether or not importing
this module will cause the GIL to be automatically enabled. See
:envvar:`PYTHON_GIL` and :option:`-X gil <-X>` for more detail.
Multiple ``Py_mod_gil`` slots may not be specified in one module definition.
If ``Py_mod_gil`` is not specified, the import machinery defaults to
``Py_MOD_GIL_USED``.
.. versionadded: 3.13
See :PEP:`489` for more details on multi-phase initialization.
Low-level module creation functions
@ -609,6 +634,19 @@ state:
.. versionadded:: 3.9
.. c:function:: int PyModule_ExperimentalSetGIL(PyObject *module, void *gil)
Indicate that *module* does or does not support running without the global
interpreter lock (GIL), using one of the values from
:c:macro:`Py_mod_gil`. It must be called during *module*'s initialization
function. If this function is not called during module initialization, the
import machinery assumes the module does not support running without the
GIL. This function is only available in Python builds configured with
:option:`--disable-gil`.
Return ``-1`` on error, ``0`` on success.
.. versionadded:: 3.13
Module lookup
^^^^^^^^^^^^^

View File

@ -22,6 +22,9 @@ typedef struct {
PyObject *md_weaklist;
// for logging purposes after md_dict is cleared
PyObject *md_name;
#ifdef Py_GIL_DISABLED
void *md_gil;
#endif
} PyModuleObject;
static inline PyModuleDef* _PyModule_GetDef(PyObject *mod) {

View File

@ -76,9 +76,13 @@ struct PyModuleDef_Slot {
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000
# define Py_mod_multiple_interpreters 3
#endif
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000
# define Py_mod_gil 4
#endif
#ifndef Py_LIMITED_API
#define _Py_mod_LAST_SLOT 3
#define _Py_mod_LAST_SLOT 4
#endif
#endif /* New in 3.5 */
@ -90,6 +94,16 @@ struct PyModuleDef_Slot {
# define Py_MOD_PER_INTERPRETER_GIL_SUPPORTED ((void *)2)
#endif
/* for Py_mod_gil: */
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d0000
# define Py_MOD_GIL_USED ((void *)0)
# define Py_MOD_GIL_NOT_USED ((void *)1)
#endif
#if !defined(Py_LIMITED_API) && defined(Py_GIL_DISABLED)
PyAPI_FUNC(int) PyModule_ExperimentalSetGIL(PyObject *module, void *gil);
#endif
struct PyModuleDef {
PyModuleDef_Base m_base;
const char* m_name;

View File

@ -0,0 +1,44 @@
import types
import unittest
from test.test_importlib import util
machinery = util.import_importlib('importlib.machinery')
from test.test_importlib.extension.test_loader import MultiPhaseExtensionModuleTests
class NonModuleExtensionTests:
setUp = MultiPhaseExtensionModuleTests.setUp
load_module_by_name = MultiPhaseExtensionModuleTests.load_module_by_name
def _test_nonmodule(self):
# Test returning a non-module object from create works.
name = self.name + '_nonmodule'
mod = self.load_module_by_name(name)
self.assertNotEqual(type(mod), type(unittest))
self.assertEqual(mod.three, 3)
# issue 27782
def test_nonmodule_with_methods(self):
# Test creating a non-module object with methods defined.
name = self.name + '_nonmodule_with_methods'
mod = self.load_module_by_name(name)
self.assertNotEqual(type(mod), type(unittest))
self.assertEqual(mod.three, 3)
self.assertEqual(mod.bar(10, 1), 9)
def test_null_slots(self):
# Test that NULL slots aren't a problem.
name = self.name + '_null_slots'
module = self.load_module_by_name(name)
self.assertIsInstance(module, types.ModuleType)
self.assertEqual(module.__name__, name)
(Frozen_NonModuleExtensionTests,
Source_NonModuleExtensionTests
) = util.test_both(NonModuleExtensionTests, machinery=machinery)
if __name__ == '__main__':
unittest.main()

View File

@ -10,7 +10,8 @@ import unittest
import warnings
import importlib.util
import importlib
from test.support import MISSING_C_DOCSTRINGS
from test import support
from test.support import MISSING_C_DOCSTRINGS, script_helper
class LoaderTests:
@ -325,29 +326,6 @@ class MultiPhaseExtensionModuleTests(abc.LoaderTests):
self.load_module_by_name(name)
self.assertEqual(cm.exception.name, name)
def test_nonmodule(self):
# Test returning a non-module object from create works.
name = self.name + '_nonmodule'
mod = self.load_module_by_name(name)
self.assertNotEqual(type(mod), type(unittest))
self.assertEqual(mod.three, 3)
# issue 27782
def test_nonmodule_with_methods(self):
# Test creating a non-module object with methods defined.
name = self.name + '_nonmodule_with_methods'
mod = self.load_module_by_name(name)
self.assertNotEqual(type(mod), type(unittest))
self.assertEqual(mod.three, 3)
self.assertEqual(mod.bar(10, 1), 9)
def test_null_slots(self):
# Test that NULL slots aren't a problem.
name = self.name + '_null_slots'
module = self.load_module_by_name(name)
self.assertIsInstance(module, types.ModuleType)
self.assertEqual(module.__name__, name)
def test_bad_modules(self):
# Test SystemError is raised for misbehaving extensions.
for name_base in [
@ -401,5 +379,14 @@ class MultiPhaseExtensionModuleTests(abc.LoaderTests):
) = util.test_both(MultiPhaseExtensionModuleTests, machinery=machinery)
class NonModuleExtensionTests(unittest.TestCase):
def test_nonmodule_cases(self):
# The test cases in this file cause the GIL to be enabled permanently
# in free-threaded builds, so they are run in a subprocess to isolate
# this effect.
script = support.findfile("test_importlib/extension/_test_nonmodule_cases.py")
script_helper.run_test_script(script)
if __name__ == '__main__':
unittest.main()

View File

@ -1606,7 +1606,10 @@ class SizeofTest(unittest.TestCase):
check(int(PyLong_BASE**2-1), vsize('') + 2*self.longdigit)
check(int(PyLong_BASE**2), vsize('') + 3*self.longdigit)
# module
check(unittest, size('PnPPP'))
if support.Py_GIL_DISABLED:
check(unittest, size('PPPPPP'))
else:
check(unittest, size('PPPPP'))
# None
check(None, size(''))
# NotImplementedType

View File

@ -0,0 +1,5 @@
Extension modules may indicate to the runtime that they can run without the
GIL. Multi-phase init modules do so by calling providing
``Py_MOD_GIL_NOT_USED`` for the ``Py_mod_gil`` slot, while single-phase init
modules call ``PyModule_ExperimentalSetGIL(mod, Py_MOD_GIL_NOT_USED)`` from
their init function.

View File

@ -970,6 +970,7 @@ _abcmodule_free(void *module)
static PyModuleDef_Slot _abcmodule_slots[] = {
{Py_mod_exec, _abcmodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -3795,6 +3795,7 @@ module_exec(PyObject *mod)
static struct PyModuleDef_Slot module_slots[] = {
{Py_mod_exec, module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};

View File

@ -462,6 +462,7 @@ bisect_modexec(PyObject *m)
static PyModuleDef_Slot bisect_slots[] = {
{Py_mod_exec, bisect_modexec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -137,6 +137,7 @@ blake2_exec(PyObject *m)
static PyModuleDef_Slot _blake2_slots[] = {
{Py_mod_exec, blake2_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -802,6 +802,7 @@ _bz2_free(void *module)
static struct PyModuleDef_Slot _bz2_slots[] = {
{Py_mod_exec, _bz2_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -1050,6 +1050,7 @@ static PyMethodDef _codecs_functions[] = {
static PyModuleDef_Slot _codecs_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -2817,6 +2817,7 @@ collections_exec(PyObject *module) {
static struct PyModuleDef_Slot collections_slots[] = {
{Py_mod_exec, collections_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -45,6 +45,7 @@ _contextvars_exec(PyObject *m)
static struct PyModuleDef_Slot _contextvars_slots[] = {
{Py_mod_exec, _contextvars_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -1796,6 +1796,7 @@ csv_exec(PyObject *module) {
static PyModuleDef_Slot csv_slots[] = {
{Py_mod_exec, csv_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -5948,6 +5948,7 @@ module_free(void *module)
static PyModuleDef_Slot module_slots[] = {
{Py_mod_exec, _ctypes_mod_exec},
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -1,7 +1,7 @@
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
// Need limited C API version 3.13 for Py_mod_gil
#include "pyconfig.h" // Py_GIL_DISABLED
#ifndef Py_GIL_DISABLED
# define Py_LIMITED_API 0x030c0000
# define Py_LIMITED_API 0x030d0000
#endif
// gh-85283: On Windows, Py_LIMITED_API requires Py_BUILD_CORE to not attempt
@ -1167,6 +1167,7 @@ _testfunc_pylist_append(PyObject *list, PyObject *item)
static struct PyModuleDef_Slot _ctypes_test_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -697,6 +697,7 @@ static PyModuleDef_Slot _curses_slots[] = {
// XXX gh-103092: fix isolation.
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
//{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -4743,6 +4743,9 @@ PyInit__curses(void)
m = PyModule_Create(&_cursesmodule);
if (m == NULL)
return NULL;
#ifdef Py_GIL_DISABLED
PyModule_ExperimentalSetGIL(m, Py_MOD_GIL_NOT_USED);
#endif
/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);

View File

@ -6984,6 +6984,9 @@ PyInit__datetime(void)
PyObject *mod = PyModule_Create(&datetimemodule);
if (mod == NULL)
return NULL;
#ifdef Py_GIL_DISABLED
PyModule_ExperimentalSetGIL(mod, Py_MOD_GIL_NOT_USED);
#endif
if (_datetime_exec(mod) < 0) {
Py_DECREF(mod);

View File

@ -616,6 +616,7 @@ _dbm_module_free(void *module)
static PyModuleDef_Slot _dbmmodule_slots[] = {
{Py_mod_exec, _dbm_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -6157,6 +6157,7 @@ decimal_free(void *module)
static struct PyModuleDef_Slot _decimal_slots[] = {
{Py_mod_exec, _decimal_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};

View File

@ -4463,6 +4463,7 @@ error:
static struct PyModuleDef_Slot elementtree_slots[] = {
{Py_mod_exec, module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};

View File

@ -1559,6 +1559,7 @@ _functools_free(void *module)
static struct PyModuleDef_Slot _functools_slots[] = {
{Py_mod_exec, _functools_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -825,6 +825,7 @@ _gdbm_module_free(void *module)
static PyModuleDef_Slot _gdbm_module_slots[] = {
{Py_mod_exec, _gdbm_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -2289,6 +2289,7 @@ static PyModuleDef_Slot hashlib_slots[] = {
{Py_mod_exec, hashlib_init_constructors},
{Py_mod_exec, hashlib_exception},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -681,6 +681,7 @@ heapq_exec(PyObject *m)
static struct PyModuleDef_Slot heapq_slots[] = {
{Py_mod_exec, heapq_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -3326,6 +3326,7 @@ error:
static struct PyModuleDef_Slot module_slots[] = {
{Py_mod_exec, module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};

View File

@ -1830,6 +1830,7 @@ error:
static struct PyModuleDef_Slot module_slots[] = {
{Py_mod_exec, module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};

View File

@ -1519,6 +1519,7 @@ error:
static struct PyModuleDef_Slot module_slots[] = {
{Py_mod_exec, module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};

View File

@ -720,6 +720,7 @@ iomodule_exec(PyObject *m)
static struct PyModuleDef_Slot iomodule_slots[] = {
{Py_mod_exec, iomodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};

View File

@ -1780,6 +1780,7 @@ _json_exec(PyObject *module)
static PyModuleDef_Slot _json_slots[] = {
{Py_mod_exec, _json_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -860,6 +860,7 @@ _locale_exec(PyObject *module)
static struct PyModuleDef_Slot _locale_slots[] = {
{Py_mod_exec, _locale_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -1006,6 +1006,7 @@ _lsprof_exec(PyObject *module)
static PyModuleDef_Slot _lsprofslots[] = {
{Py_mod_exec, _lsprof_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -1604,6 +1604,7 @@ static PyMethodDef lzma_methods[] = {
static PyModuleDef_Slot lzma_slots[] = {
{Py_mod_exec, lzma_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -277,6 +277,7 @@ multiprocessing_exec(PyObject *module)
static PyModuleDef_Slot multiprocessing_slots[] = {
{Py_mod_exec, multiprocessing_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -2,10 +2,10 @@
posixshmem - A Python extension that provides shm_open() and shm_unlink()
*/
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
// Need limited C API version 3.13 for Py_mod_gil
#include "pyconfig.h" // Py_GIL_DISABLED
#ifndef Py_GIL_DISABLED
# define Py_LIMITED_API 0x030c0000
# define Py_LIMITED_API 0x030d0000
#endif
#include <Python.h>
@ -128,6 +128,7 @@ static PyMethodDef module_methods[ ] = {
static PyModuleDef_Slot module_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -406,6 +406,7 @@ _opcode_exec(PyObject *m) {
static PyModuleDef_Slot module_slots[] = {
{Py_mod_exec, _opcode_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -1928,6 +1928,7 @@ operator_exec(PyObject *module)
static struct PyModuleDef_Slot operator_slots[] = {
{Py_mod_exec, operator_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -7863,6 +7863,7 @@ _pickle_exec(PyObject *m)
static PyModuleDef_Slot pickle_slots[] = {
{Py_mod_exec, _pickle_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};

View File

@ -1317,6 +1317,7 @@ static PyMethodDef module_methods[] = {
static PyModuleDef_Slot _posixsubprocess_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -594,6 +594,7 @@ queuemodule_exec(PyObject *module)
static PyModuleDef_Slot queuemodule_slots[] = {
{Py_mod_exec, queuemodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -642,6 +642,7 @@ _random_exec(PyObject *module)
static PyModuleDef_Slot _random_slots[] = {
{Py_mod_exec, _random_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -3,10 +3,10 @@
* using the SystemConfiguration framework.
*/
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
// Need limited C API version 3.13 for Py_mod_gil
#include "pyconfig.h" // Py_GIL_DISABLED
#ifndef Py_GIL_DISABLED
# define Py_LIMITED_API 0x030c0000
# define Py_LIMITED_API 0x030d0000
#endif
#include <Python.h>
@ -239,6 +239,7 @@ static PyMethodDef mod_methods[] = {
static PyModuleDef_Slot _scproxy_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -758,6 +758,7 @@ error:
static struct PyModuleDef_Slot module_slots[] = {
{Py_mod_exec, module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};

View File

@ -3272,6 +3272,7 @@ error:
static PyModuleDef_Slot sre_slots[] = {
{Py_mod_exec, sre_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};

View File

@ -6515,6 +6515,7 @@ static PyModuleDef_Slot sslmodule_slots[] = {
{Py_mod_exec, sslmodule_init_strings},
{Py_mod_exec, sslmodule_init_lock},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -679,6 +679,7 @@ stat_exec(PyObject *module)
static PyModuleDef_Slot stat_slots[] = {
{Py_mod_exec, stat_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -1,9 +1,9 @@
/* statistics accelerator C extension: _statistics module. */
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
// Need limited C API version 3.13 for Py_mod_gil
#include "pyconfig.h" // Py_GIL_DISABLED
#ifndef Py_GIL_DISABLED
# define Py_LIMITED_API 0x030c0000
# define Py_LIMITED_API 0x030d0000
#endif
#include "Python.h"
@ -136,6 +136,7 @@ PyDoc_STRVAR(statistics_doc,
static struct PyModuleDef_Slot _statisticsmodule_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -2593,6 +2593,7 @@ _structmodule_exec(PyObject *m)
static PyModuleDef_Slot _structmodule_slots[] = {
{Py_mod_exec, _structmodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -49,15 +49,21 @@ static PyMethodDef module_methods[] = {
{NULL, NULL, 0, NULL} // Sentinel
};
static PyModuleDef_Slot module_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};
static struct PyModuleDef suggestions_module = {
PyModuleDef_HEAD_INIT,
"_suggestions",
NULL,
-1,
module_methods
0,
module_methods,
module_slots,
};
PyMODINIT_FUNC PyInit__suggestions(void) {
return PyModule_Create(&suggestions_module);
return PyModuleDef_Init(&suggestions_module);
}

View File

@ -80,6 +80,7 @@ static struct PyMethodDef sysconfig_methods[] = {
static PyModuleDef_Slot sysconfig_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -2901,6 +2901,9 @@ PyInit__testbuffer(void)
if (mod == NULL) {
return NULL;
}
#ifdef Py_GIL_DISABLED
PyModule_ExperimentalSetGIL(mod, Py_MOD_GIL_NOT_USED);
#endif
if (_testbuffer_exec(mod) < 0) {
Py_DECREF(mod);
return NULL;

View File

@ -3935,6 +3935,9 @@ PyInit__testcapi(void)
m = PyModule_Create(&_testcapimodule);
if (m == NULL)
return NULL;
#ifdef Py_GIL_DISABLED
PyModule_ExperimentalSetGIL(m, Py_MOD_GIL_NOT_USED);
#endif
Py_SET_TYPE(&_HashInheritanceTester_Type, &PyType_Type);
if (PyType_Ready(&_HashInheritanceTester_Type) < 0) {

View File

@ -1955,6 +1955,9 @@ PyInit__testclinic(void)
if (m == NULL) {
return NULL;
}
#ifdef Py_GIL_DISABLED
PyModule_ExperimentalSetGIL(m, Py_MOD_GIL_NOT_USED);
#endif
if (PyModule_AddType(m, &TestClass) < 0) {
goto error;
}

View File

@ -146,5 +146,8 @@ PyInit__testclinic_limited(void)
if (m == NULL) {
return NULL;
}
#ifdef Py_GIL_DISABLED
PyModule_ExperimentalSetGIL(m, Py_MOD_GIL_NOT_USED);
#endif
return m;
}

View File

@ -627,6 +627,12 @@ PyMODINIT_FUNC
PyInit__testexternalinspection(void)
{
PyObject* mod = PyModule_Create(&module);
if (mod == NULL) {
return NULL;
}
#ifdef Py_GIL_DISABLED
PyModule_ExperimentalSetGIL(mod, Py_MOD_GIL_NOT_USED);
#endif
int rc = PyModule_AddIntConstant(mod, "PROCESS_VM_READV_SUPPORTED", HAVE_PROCESS_VM_READV);
if (rc < 0) {
Py_DECREF(mod);

View File

@ -6,18 +6,24 @@
#include "pyconfig.h" // Py_GIL_DISABLED
#ifndef Py_GIL_DISABLED
# define Py_LIMITED_API 0x03020000
# define Py_LIMITED_API 0x030d0000
#endif
#include <Python.h>
static PyModuleDef_Slot shared_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};
static struct PyModuleDef _testimportmultiple = {
PyModuleDef_HEAD_INIT,
"_testimportmultiple",
"_testimportmultiple doc",
-1,
NULL,
0,
NULL,
shared_slots,
NULL,
NULL,
NULL
@ -25,16 +31,16 @@ static struct PyModuleDef _testimportmultiple = {
PyMODINIT_FUNC PyInit__testimportmultiple(void)
{
return PyModule_Create(&_testimportmultiple);
return PyModuleDef_Init(&_testimportmultiple);
}
static struct PyModuleDef _foomodule = {
PyModuleDef_HEAD_INIT,
"_testimportmultiple_foo",
"_testimportmultiple_foo doc",
-1,
NULL,
0,
NULL,
shared_slots,
NULL,
NULL,
NULL
@ -42,21 +48,21 @@ static struct PyModuleDef _foomodule = {
PyMODINIT_FUNC PyInit__testimportmultiple_foo(void)
{
return PyModule_Create(&_foomodule);
return PyModuleDef_Init(&_foomodule);
}
static struct PyModuleDef _barmodule = {
PyModuleDef_HEAD_INIT,
"_testimportmultiple_bar",
"_testimportmultiple_bar doc",
-1,
NULL,
0,
NULL,
shared_slots,
NULL,
NULL,
NULL
};
PyMODINIT_FUNC PyInit__testimportmultiple_bar(void){
return PyModule_Create(&_barmodule);
return PyModuleDef_Init(&_barmodule);
}

View File

@ -2142,6 +2142,7 @@ module_exec(PyObject *module)
static struct PyModuleDef_Slot module_slots[] = {
{Py_mod_exec, module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};

View File

@ -25,6 +25,9 @@ PyInit__testlimitedcapi(void)
if (mod == NULL) {
return NULL;
}
#ifdef Py_GIL_DISABLED
PyModule_ExperimentalSetGIL(mod, Py_MOD_GIL_NOT_USED);
#endif
if (_PyTestLimitedCAPI_Init_Abstract(mod) < 0) {
return NULL;

View File

@ -431,6 +431,7 @@ static int execfunc(PyObject *m)
static PyModuleDef_Slot main_slots[] = {
{Py_mod_exec, execfunc},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};
@ -519,13 +520,18 @@ PyInit__testmultiphase_nonmodule_with_methods(void)
/**** Non-ASCII-named modules ****/
static PyModuleDef_Slot nonascii_slots[] = {
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};
static PyModuleDef def_nonascii_latin = { \
PyModuleDef_HEAD_INIT, /* m_base */
"_testmultiphase_nonascii_latin", /* m_name */
PyDoc_STR("Module named in Czech"), /* m_doc */
0, /* m_size */
NULL, /* m_methods */
NULL, /* m_slots */
nonascii_slots, /* m_slots */
NULL, /* m_traverse */
NULL, /* m_clear */
NULL, /* m_free */
@ -543,7 +549,7 @@ static PyModuleDef def_nonascii_kana = { \
PyDoc_STR("Module named in Japanese"), /* m_doc */
0, /* m_size */
NULL, /* m_methods */
NULL, /* m_slots */
nonascii_slots, /* m_slots */
NULL, /* m_traverse */
NULL, /* m_clear */
NULL, /* m_free */
@ -757,6 +763,7 @@ static PyModuleDef_Slot slots_nonmodule_with_exec_slots[] = {
{Py_mod_create, createfunc_nonmodule},
{Py_mod_exec, execfunc},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};
@ -778,6 +785,7 @@ execfunc_err(PyObject *mod)
static PyModuleDef_Slot slots_exec_err[] = {
{Py_mod_exec, execfunc_err},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};
@ -800,6 +808,7 @@ execfunc_raise(PyObject *spec)
static PyModuleDef_Slot slots_exec_raise[] = {
{Py_mod_exec, execfunc_raise},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};
@ -822,6 +831,7 @@ execfunc_unreported_exception(PyObject *mod)
static PyModuleDef_Slot slots_exec_unreported_exception[] = {
{Py_mod_exec, execfunc_unreported_exception},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};
@ -857,6 +867,7 @@ meth_state_access_exec(PyObject *m)
static PyModuleDef_Slot meth_state_access_slots[] = {
{Py_mod_exec, meth_state_access_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};
@ -889,6 +900,9 @@ PyInit__test_module_state_shared(void)
if (module == NULL) {
return NULL;
}
#ifdef Py_GIL_DISABLED
PyModule_ExperimentalSetGIL(module, Py_MOD_GIL_NOT_USED);
#endif
if (PyModule_AddObjectRef(module, "Error", PyExc_Exception) < 0) {
Py_DECREF(module);
@ -903,6 +917,7 @@ PyInit__test_module_state_shared(void)
static PyModuleDef_Slot slots_multiple_multiple_interpreters_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};
@ -920,6 +935,7 @@ PyInit__testmultiphase_multiple_multiple_interpreters_slots(void)
static PyModuleDef_Slot non_isolated_slots[] = {
{Py_mod_exec, execfunc},
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};
@ -940,6 +956,7 @@ static PyModuleDef_Slot shared_gil_only_slots[] = {
We put it here explicitly to draw attention to the contrast
with Py_MOD_PER_INTERPRETER_GIL_SUPPORTED. */
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};

View File

@ -471,6 +471,9 @@ init__testsinglephase_basic(PyModuleDef *def)
if (module == NULL) {
return NULL;
}
#ifdef Py_GIL_DISABLED
PyModule_ExperimentalSetGIL(module, Py_MOD_GIL_NOT_USED);
#endif
module_state *state = &global_state.module;
// It may have been set by a previous run or under a different name.
@ -562,6 +565,9 @@ PyInit__testsinglephase_with_reinit(void)
if (module == NULL) {
return NULL;
}
#ifdef Py_GIL_DISABLED
PyModule_ExperimentalSetGIL(module, Py_MOD_GIL_NOT_USED);
#endif
assert(get_module_state(module) == NULL);
@ -624,6 +630,9 @@ PyInit__testsinglephase_with_state(void)
if (module == NULL) {
return NULL;
}
#ifdef Py_GIL_DISABLED
PyModule_ExperimentalSetGIL(module, Py_MOD_GIL_NOT_USED);
#endif
module_state *state = get_module_state(module);
assert(state != NULL);

View File

@ -2544,6 +2544,7 @@ The 'threading' module provides a more convenient interface.");
static PyModuleDef_Slot thread_module_slots[] = {
{Py_mod_exec, thread_module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -3205,6 +3205,9 @@ PyInit__tkinter(void)
m = PyModule_Create(&_tkintermodule);
if (m == NULL)
return NULL;
#ifdef Py_GIL_DISABLED
PyModule_ExperimentalSetGIL(m, Py_MOD_GIL_NOT_USED);
#endif
Tkinter_TclError = PyErr_NewException("_tkinter.TclError", NULL, NULL);
if (PyModule_AddObjectRef(m, "TclError", Tkinter_TclError)) {

View File

@ -219,6 +219,9 @@ PyInit__tracemalloc(void)
m = PyModule_Create(&module_def);
if (m == NULL)
return NULL;
#ifdef Py_GIL_DISABLED
PyModule_ExperimentalSetGIL(m, Py_MOD_GIL_NOT_USED);
#endif
if (_PyTraceMalloc_Init() < 0) {
Py_DECREF(m);

View File

@ -72,6 +72,7 @@ _typing_exec(PyObject *m)
static struct PyModuleDef_Slot _typingmodule_slots[] = {
{Py_mod_exec, _typing_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -3,10 +3,10 @@
* DCE compatible Universally Unique Identifier library.
*/
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
// Need limited C API version 3.13 for Py_mod_gil
#include "pyconfig.h" // Py_GIL_DISABLED
#ifndef Py_GIL_DISABLED
# define Py_LIMITED_API 0x030c0000
# define Py_LIMITED_API 0x030d0000
#endif
#include "Python.h"
@ -111,6 +111,7 @@ static PyMethodDef uuid_methods[] = {
static PyModuleDef_Slot uuid_slots[] = {
{Py_mod_exec, uuid_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -171,6 +171,7 @@ weakref_exec(PyObject *module)
static struct PyModuleDef_Slot weakref_slots[] = {
{Py_mod_exec, weakref_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -3189,6 +3189,7 @@ static int winapi_exec(PyObject *m)
static PyModuleDef_Slot winapi_slots[] = {
{Py_mod_exec, winapi_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -28,13 +28,18 @@ static PyMethodDef module_methods[] = {
{NULL},
};
static PyModuleDef_Slot module_slots[] = {
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};
static struct PyModuleDef _fuzzmodule = {
PyModuleDef_HEAD_INIT,
"_fuzz",
NULL,
0,
module_methods,
NULL,
module_slots,
NULL,
NULL,
NULL
@ -43,5 +48,5 @@ static struct PyModuleDef _fuzzmodule = {
PyMODINIT_FUNC
PyInit__xxtestfuzz(void)
{
return PyModule_Create(&_fuzzmodule);
return PyModuleDef_Init(&_fuzzmodule);
}

View File

@ -2760,6 +2760,7 @@ error:
static PyModuleDef_Slot zoneinfomodule_slots[] = {
{Py_mod_exec, zoneinfomodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};

View File

@ -3220,6 +3220,7 @@ array_modexec(PyObject *m)
static PyModuleDef_Slot arrayslots[] = {
{Py_mod_exec, array_modexec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -322,6 +322,7 @@ Two public functions, register and unregister, are defined.\n\
static PyModuleDef_Slot atexitmodule_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -1278,6 +1278,7 @@ binascii_exec(PyObject *module)
static PyModuleDef_Slot binascii_slots[] = {
{Py_mod_exec, binascii_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -503,6 +503,7 @@ static struct PyMethodDef _cjk_methods[] = {
static PyModuleDef_Slot _cjk_slots[] = {
{Py_mod_exec, _cjk_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -2094,6 +2094,7 @@ static struct PyMethodDef _multibytecodec_methods[] = {
static PyModuleDef_Slot _multibytecodec_slots[] = {
{Py_mod_exec, _multibytecodec_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -1363,6 +1363,7 @@ cmath_exec(PyObject *mod)
static PyModuleDef_Slot cmath_slots[] = {
{Py_mod_exec, cmath_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -1,9 +1,9 @@
/* Errno module */
// Need limited C API version 3.12 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
// Need limited C API version 3.13 for Py_mod_gil
#include "pyconfig.h" // Py_GIL_DISABLED
#ifndef Py_GIL_DISABLED
# define Py_LIMITED_API 0x030c0000
# define Py_LIMITED_API 0x030d0000
#endif
#include "Python.h"
@ -951,6 +951,7 @@ errno_exec(PyObject *module)
static PyModuleDef_Slot errno_slots[] = {
{Py_mod_exec, errno_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -1292,6 +1292,7 @@ static PyModuleDef_Slot faulthandler_slots[] = {
{Py_mod_exec, PyExec_faulthandler},
// XXX gh-103092: fix isolation.
//{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -745,6 +745,7 @@ fcntl_exec(PyObject *module)
static PyModuleDef_Slot fcntl_slots[] = {
{Py_mod_exec, fcntl_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -535,6 +535,7 @@ gcmodule_exec(PyObject *module)
static PyModuleDef_Slot gcmodule_slots[] = {
{Py_mod_exec, gcmodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -342,6 +342,7 @@ grpmodule_exec(PyObject *module)
static PyModuleDef_Slot grpmodule_slots[] = {
{Py_mod_exec, grpmodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -4781,6 +4781,7 @@ itertoolsmodule_exec(PyObject *mod)
static struct PyModuleDef_Slot itertoolsmodule_slots[] = {
{Py_mod_exec, itertoolsmodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -4177,6 +4177,7 @@ static PyMethodDef math_methods[] = {
static PyModuleDef_Slot math_slots[] = {
{Py_mod_exec, math_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -375,6 +375,7 @@ md5_exec(PyObject *m)
static PyModuleDef_Slot _md5_slots[] = {
{Py_mod_exec, md5_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -1801,6 +1801,7 @@ mmap_exec(PyObject *module)
static PyModuleDef_Slot mmap_slots[] = {
{Py_mod_exec, mmap_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -2070,6 +2070,7 @@ overlapped_exec(PyObject *module)
static PyModuleDef_Slot overlapped_slots[] = {
{Py_mod_exec, overlapped_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -18071,6 +18071,7 @@ posixmodule_exec(PyObject *m)
static PyModuleDef_Slot posixmodile_slots[] = {
{Py_mod_exec, posixmodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -344,6 +344,7 @@ pwdmodule_exec(PyObject *module)
static PyModuleDef_Slot pwdmodule_slots[] = {
{Py_mod_exec, pwdmodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -2117,6 +2117,7 @@ pyexpat_free(void *module)
static PyModuleDef_Slot pyexpat_slots[] = {
{Py_mod_exec, pyexpat_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -1552,6 +1552,9 @@ PyInit_readline(void)
if (m == NULL)
return NULL;
#ifdef Py_GIL_DISABLED
PyModule_ExperimentalSetGIL(m, Py_MOD_GIL_NOT_USED);
#endif
if (PyModule_AddIntConstant(m, "_READLINE_VERSION",
RL_READLINE_VERSION) < 0) {

View File

@ -513,6 +513,7 @@ resource_exec(PyObject *module)
static struct PyModuleDef_Slot resource_slots[] = {
{Py_mod_exec, resource_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -2802,6 +2802,7 @@ _select_exec(PyObject *m)
static PyModuleDef_Slot _select_slots[] = {
{Py_mod_exec, _select_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -371,6 +371,7 @@ _sha1_exec(PyObject *module)
static PyModuleDef_Slot _sha1_slots[] = {
{Py_mod_exec, _sha1_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -866,6 +866,7 @@ static int sha2_exec(PyObject *module)
static PyModuleDef_Slot _sha2_slots[] = {
{Py_mod_exec, sha2_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -602,6 +602,7 @@ _sha3_exec(PyObject *m)
static PyModuleDef_Slot _sha3_slots[] = {
{Py_mod_exec, _sha3_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -1698,6 +1698,7 @@ _signal_module_free(void *module)
static PyModuleDef_Slot signal_slots[] = {
{Py_mod_exec, signal_module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

View File

@ -8896,6 +8896,7 @@ error:
static struct PyModuleDef_Slot socket_slots[] = {
{Py_mod_exec, socket_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL},
};

View File

@ -110,6 +110,7 @@ symtable_init_constants(PyObject *m)
static PyModuleDef_Slot symtable_slots[] = {
{Py_mod_exec, symtable_init_constants},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
{0, NULL}
};

Some files were not shown because too many files have changed in this diff Show More