Author: Armin Rigo <[email protected]>
Branch: cpyext-gil-ensure
Changeset: r83252:3d0bee673d77
Date: 2016-03-22 15:34 +0100
http://bitbucket.org/pypy/pypy/changeset/3d0bee673d77/
Log: fixes
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -268,6 +268,9 @@
argnames, varargname, kwargname =
pycode.cpython_code_signature(callable.func_code)
assert argnames[0] == 'space'
+ if gil == 'pygilstate_ensure':
+ assert argnames[-1] == 'previous_state'
+ del argnames[-1]
self.argnames = argnames[1:]
assert len(self.argnames) == len(self.argtypes)
self.gil = gil
@@ -678,9 +681,9 @@
assert (gil is None or gil_acquire or gil_release
or pygilstate_ensure or pygilstate_release)
deadlock_error = ("GIL deadlock detected when a CPython C extension "
- "module calls back %r" % (callable.__name__,))
+ "module calls %r" % (callable.__name__,))
no_gil_error = ("GIL not held when a CPython C extension "
- "module calls back %r" % (callable.__name__,))
+ "module calls %r" % (callable.__name__,))
@specialize.ll()
def wrapper(*args):
@@ -717,7 +720,8 @@
try:
if not we_are_translated() and DEBUG_WRAPPER:
print >>sys.stderr, callable,
- assert len(args) == len(callable.api_func.argtypes)
+ assert len(args) == (len(callable.api_func.argtypes) +
+ pygilstate_ensure)
for i, (typ, is_wrapped) in argtypes_enum_ui:
arg = args[i]
if is_PyObject(typ) and is_wrapped:
@@ -726,6 +730,8 @@
else:
arg_conv = arg
boxed_args += (arg_conv, )
+ if pygilstate_ensure:
+ boxed_args += (args[-1], )
state = space.fromcache(State)
try:
result = callable(space, *boxed_args)
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
@@ -26,7 +26,6 @@
# Should compile at least
module.test()
- @pytest.mark.xfail(reason='hangs at rgil.acquire', run=False)
def test_gilstate(self):
module = self.import_extension('foo', [
("double_ensure", "METH_O",
diff --git a/rpython/rlib/rthread.py b/rpython/rlib/rthread.py
--- a/rpython/rlib/rthread.py
+++ b/rpython/rlib/rthread.py
@@ -104,7 +104,7 @@
return tlfield_thread_ident.get_or_make_raw()
else:
import thread
- retrun thread.get_ident()
+ return thread.get_ident()
@specialize.arg(0)
def start_new_thread(x, y):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit