[Python-checkins] r77934 - in python/branches/py3k: Modules/_testcapimodule.c

benjamin.peterson python-checkins at python.org
Wed Feb 3 02:13:41 CET 2010


Author: benjamin.peterson
Date: Wed Feb 3 02:13:41 2010
New Revision: 77934
Log:
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 (2010年1月30日) | 1 line
 
 move test outside WITH_THREAD section
........
 r77867 | benjamin.peterson | 2010年01月30日 17:28:38 -0600 (2010年1月30日) | 1 line
 
 be robust against test being run over and over (such as -R)
........
Modified:
 python/branches/py3k/ (props changed)
 python/branches/py3k/Modules/_testcapimodule.c
Modified: python/branches/py3k/Modules/_testcapimodule.c
==============================================================================
--- python/branches/py3k/Modules/_testcapimodule.c	(original)
+++ python/branches/py3k/Modules/_testcapimodule.c	Wed Feb 3 02:13:41 2010
@@ -1362,15 +1362,23 @@
 	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 @@
 		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


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /