Author: mattip <[email protected]>
Branch: cpyext-ext
Changeset: r83810:80bae955e12e
Date: 2016-04-21 22:57 +0300
http://bitbucket.org/pypy/pypy/changeset/80bae955e12e/

Log:    fix test, PyThreadState_Get() cannot be called after
        PyEval_SaveThread since the state is set to NULL

diff --git a/pypy/module/cpyext/test/test_pystate.py 
b/pypy/module/cpyext/test/test_pystate.py
--- a/pypy/module/cpyext/test/test_pystate.py
+++ b/pypy/module/cpyext/test/test_pystate.py
@@ -118,19 +118,20 @@
         module = self.import_extension('foo', [
                 ("bounce", "METH_NOARGS",
                  """
+                 if (PyEval_ThreadsInitialized() == 0)
+                 {
+                    PyEval_InitThreads();
+                 }
+                 PyGILState_Ensure();
                  PyThreadState *tstate = PyEval_SaveThread();
                  if (tstate == NULL) {
                      return PyLong_FromLong(0);
                  }
 
-                 if (PyThreadState_Get() != NULL) {
-                     return PyLong_FromLong(1);
-                 }
-
                  PyEval_RestoreThread(tstate);
 
                  if (PyThreadState_Get() != tstate) {
-                     return PyLong_FromLong(2);
+                     return PyLong_FromLong(1);
                  }
 
                  return PyLong_FromLong(3);
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to