summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 55475c7..cefcbff 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -1362,15 +1362,23 @@ raise_exception(PyObject *self, PyObject *args)
return NULL;
}
-#ifdef WITH_THREAD
+
+static int test_run_counter = 0;
static PyObject *
test_datetime_capi(PyObject *self, PyObject *args) {
if (PyDateTimeAPI) {
- PyErr_SetString(PyExc_AssertionError,
- "PyDateTime_CAPI somehow initialized");
- return NULL;
+ if (test_run_counter) {
+ /* Probably regrtest.py -R */
+ Py_RETURN_NONE;
+ }
+ else {
+ PyErr_SetString(PyExc_AssertionError,
+ "PyDateTime_CAPI somehow initialized");
+ return NULL;
+ }
}
+ test_run_counter++;
PyDateTime_IMPORT;
if (PyDateTimeAPI)
Py_RETURN_NONE;
@@ -1378,6 +1386,9 @@ test_datetime_capi(PyObject *self, PyObject *args) {
return NULL;
}
+
+#ifdef WITH_THREAD
+
/* test_thread_state spawns a thread of its own, and that thread releases
* `thread_done` when it's finished. The driver code has to know when the
* thread finishes, because the thread uses a PyObject (the callable) that