[pypy-commit] pypy cpyext-ext: fix test, PyThreadState_Get() cannot be called after PyEval_SaveThread since the state is set to NULL
mattip
pypy.commits at gmail.com
Thu Apr 21 15:58:35 EDT 2016
Author: mattip <matti.picus at gmail.com>
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);
More information about the pypy-commit
mailing list