[pypy-svn] r74102 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test

afa at codespeak.net afa at codespeak.net
Tue Apr 27 10:50:44 CEST 2010


Author: afa
Date: Tue Apr 27 10:50:42 2010
New Revision: 74102

Modified:
   pypy/branch/cpython-extension/pypy/module/cpyext/pystate.py
   pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py
Log:
Fix PyEval_SaveThread, which crashed when the thread module is compiled,
but no thread has been started


Modified: pypy/branch/cpython-extension/pypy/module/cpyext/pystate.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/pystate.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/pystate.py	Tue Apr 27 10:50:42 2010
@@ -13,9 +13,8 @@
     previous thread state (which is not NULL except in PyPy).  If the lock has been created,
     the current thread must have acquired it.  (This function is available even
     when thread support is disabled at compile time.)"""
-    if space.config.objspace.usemodules.thread:
-        from pypy.module.thread.gil import before_external_call
-        before_external_call()
+    if rffi.aroundstate.before:
+        rffi.aroundstate.before()
     return lltype.nullptr(PyThreadState.TO)
 
 @cpython_api([PyThreadState], lltype.Void)
@@ -25,9 +24,8 @@
     NULL.  If the lock has been created, the current thread must not have
     acquired it, otherwise deadlock ensues.  (This function is available even
     when thread support is disabled at compile time.)"""
-    if space.config.objspace.usemodules.thread:
-        from pypy.module.thread.gil import after_external_call
-        after_external_call()
+    if rffi.aroundstate.after:
+        rffi.aroundstate.after()
 
 @cpython_api([], lltype.Void)
 def PyEval_InitThreads(space):

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_cpyext.py	Tue Apr 27 10:50:42 2010
@@ -40,7 +40,7 @@
 
 class AppTestApi:
     def setup_class(cls):
-        cls.space = gettestobjspace(usemodules=['cpyext'])
+        cls.space = gettestobjspace(usemodules=['cpyext', 'thread'])
         from pypy.rlib.libffi import get_libc_name
         cls.w_libc = cls.space.wrap(get_libc_name())
 
@@ -129,7 +129,7 @@
 
 class AppTestCpythonExtensionBase:
     def setup_class(cls):
-        cls.space = gettestobjspace(usemodules=['cpyext'])
+        cls.space = gettestobjspace(usemodules=['cpyext', 'thread'])
         cls.space.getbuiltinmodule("cpyext")
 
     def import_module(self, name, init=None, body='', load_it=True):



More information about the Pypy-commit mailing list