summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-02-03 01:13:41 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-02-03 01:13:41 (GMT)
commit16323988ba164480233cdc284e2aaf0018985856 (patch)
treec5e3a35f0eb54717a6d2be641aa4446fec660507 /Modules/_testcapimodule.c
parentba0eacffd8a421ef6d12508585e09da3c07bc802 (diff)
downloadcpython-16323988ba164480233cdc284e2aaf0018985856.zip
cpython-16323988ba164480233cdc284e2aaf0018985856.tar.gz
cpython-16323988ba164480233cdc284e2aaf0018985856.tar.bz2
Merged revisions 77866-77867 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r77866 | benjamin.peterson | 2010-01-30 17:26:05 -0600 (Sat, 30 Jan 2010) | 1 line move test outside WITH_THREAD section ........ r77867 | benjamin.peterson | 2010-01-30 17:28:38 -0600 (Sat, 30 Jan 2010) | 1 line be robust against test being run over and over (such as -R) ........
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