8000 [3.13] gh-117398: Revert gh-119636, Add multiphase support to _dateti… · python/cpython@9216a53 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9216a53

Browse files
[3.13] gh-117398: Revert gh-119636, Add multiphase support to _datetime (#119639)
Revert "[3.13] gh-117398: Add multiphase support to _datetime (gh-119373) (gh-119636)" This reverts commit d58ebf0.
1 parent 7322ff1 commit 9216a53

File tree

2 files changed

+15
-32
lines changed

2 files changed

+15
-32
lines changed

Lib/test/datetimetester.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,6 @@
4747
pass
4848
#
4949

50-
# This is copied from test_import/__init__.py.
51-
# XXX Move it to support/__init__.py.
52-
def no_rerun(reason):
53-
"""Skip rerunning for a particular test.
54-
55-
WARNING: Use this decorator with care; skipping rerunning makes it
56-
impossible to find reference leaks. Provide a clear reason for skipping the
57-
test using the 'reason' parameter.
58-
"""
59-
def deco(func):
60-
_has_run = False
61-
def wrapper(self):
62-
nonlocal _has_run
63-
if _has_run:
64-
self.skipTest(reason)
65-
func(self)
66-
_has_run = True
67-
return wrapper
68-
return deco
69-
7050
pickle_loads = {pickle.loads, pickle._loads}
7151

7252
pickle_choices = [(pickle, pickle, proto)
@@ -6403,7 +6383,6 @@ class IranTest(ZoneInfoTest):
64036383

64046384

64056385
@unittest.skipIf(_testcapi is None, 'need _testcapi module')
6406-
@no_rerun("the encapsulated datetime C API does not support reloading")
64076386
class CapiTest(unittest.TestCase):
64086387
def setUp(self):
64096388
# Since the C API is not present in the _Pure tests, skip all tests

Modules/_datetimemodule.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6970,26 +6970,30 @@ _datetime_exec(PyObject *module)
69706970
}
69716971
#undef DATETIME_ADD_MACRO
69726972

6973-
static PyModuleDef_Slot module_slots[] = {
6974-
{Py_mod_exec, _datetime_exec},
6975-
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
6976-
{Py_mod_gil, Py_MOD_GIL_NOT_USED},
6977-
{0, NULL},
6978-
};
6979-
6980-
static PyModuleDef datetimemodule = {
6973+
static struct PyModuleDef datetimemodule = {
69816974
.m_base = PyModuleDef_HEAD_INIT,
69826975
.m_name = "_datetime",
69836976
.m_doc = "Fast implementation of the datetime type.",
6984-
.m_size = 0,
6977+
.m_size = -1,
69856978
.m_methods = module_methods,
6986-
.m_slots = module_slots,
69876979
};
69886980

69896981
PyMODINIT_FUNC
69906982
PyInit__datetime(void)
69916983
{
6992-
return PyModuleDef_Init(&datetimemodule);
6984+
PyObject *mod = PyModule_Create(&datetimemodule);
6985+
if (mod == NULL)
6986+
return NULL;
6987+
#ifdef Py_GIL_DISABLED
6988+
PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED);
6989+
#endif
6990+
6991+
if (_datetime_exec(mod) < 0) {
6992+
Py_DECREF(mod);
6993+
return NULL;
6994+
}
6995+
6996+
return mod;
69936997
}
69946998

69956999
/* ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)
0