File tree 2 files changed +32
-15
lines changed
2 files changed +32
-15
lines changed Original file line number Diff line number Diff line change 47
47
pass
48
48
#
49
49
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
+
50
70
pickle_loads = {pickle .loads , pickle ._loads }
51
71
52
72
pickle_choices = [(pickle , pickle , proto )
@@ -6383,6 +6403,7 @@ class IranTest(ZoneInfoTest):
6383
6403
6384
6404
6385
6405
@unittest .skipIf (_testcapi is None , 'need _testcapi module' )
6406
+ @no_rerun ("the encapsulated datetime C API does not support reloading" )
6386
6407
class CapiTest (unittest .TestCase ):
6387
6408
def setUp (self ):
6388
6409
# Since the C API is not present in the _Pure tests, skip all tests
Original file line number Diff line number Diff line change @@ -7040,30 +7040,26 @@ _datetime_exec(PyObject *module)
7040
7040
}
7041
7041
#undef DATETIME_ADD_MACRO
7042
7042
7043
- static struct PyModuleDef datetimemodule = {
7043
+ static PyModuleDef_Slot module_slots [] = {
7044
+ {Py_mod_exec , _datetime_exec },
7045
+ {Py_mod_multiple_interpreters , Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED },
7046
+ {Py_mod_gil , Py_MOD_GIL_NOT_USED },
7047
+ {0 , NULL },
7048
+ };
7049
+
7050
+ static PyModuleDef datetimemodule = {
7044
7051
.m_base = PyModuleDef_HEAD_INIT ,
7045
7052
.m_name = "_datetime" ,
7046
7053
.m_doc = "Fast implementation of the datetime type." ,
7047
- .m_size = -1 ,
7054
+ .m_size = 0 ,
7048
7055
.m_methods = module_methods ,
7056
+ .m_slots = module_slots ,
7049
7057
};
7050
7058
7051
7059
PyMODINIT_FUNC
7052
7060
PyInit__datetime (void )
7053
7061
{
7054
- PyObject * mod = PyModule_Create (& datetimemodule );
7055
- if (mod == NULL )
7056
- return NULL ;
7057
- #ifdef Py_GIL_DISABLED
7058
- PyUnstable_Module_SetGIL (mod , Py_MOD_GIL_NOT_USED );
7059
- #endif
7060
-
7061
- if (_datetime_exec (mod ) < 0 ) {
7062
- Py_DECREF (mod );
7063
- return NULL ;
7064
- }
7065
-
7066
- return mod ;
7062
+ return PyModuleDef_Init (& datetimemodule );
7067
7063
}
7068
7064
7069
7065
/* ---------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments