[pypy-svn] r74210 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test
exarkun at codespeak.net
exarkun at codespeak.net
Thu Apr 29 00:52:56 CEST 2010
Author: exarkun
Date: Thu Apr 29 00:52:55 2010
New Revision: 74210
Added:
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_thread.py
pypy/branch/cpython-extension/pypy/module/cpyext/thread.py
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/__init__.py
Log:
Add PyThread_get_thread_ident
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/__init__.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/__init__.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/__init__.py Thu Apr 29 00:52:55 2010
@@ -38,6 +38,7 @@
state.non_heaptypes[:] = []
# import these modules to register api functions by side-effect
+import pypy.module.cpyext.thread
import pypy.module.cpyext.pyobject
import pypy.module.cpyext.boolobject
import pypy.module.cpyext.floatobject
Added: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_thread.py
==============================================================================
--- (empty file)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_thread.py Thu Apr 29 00:52:55 2010
@@ -0,0 +1,20 @@
+
+import thread, threading
+
+from pypy.module.cpyext.test.test_api import BaseApiTest
+
+
+class TestPyThread(BaseApiTest):
+ def test_get_thread_ident(self, space, api):
+ results = []
+ def some_thread():
+ w_res = api.PyThread_get_thread_ident(space)
+ results.append((space.int_w(w_res), thread.get_ident()))
+
+ some_thread()
+ assert results[0][0] == results[0][1]
+
+ th = threading.Thread(target=some_thread, args=())
+ th.start()
+ th.join()
+ assert results[1][0] == results[1][1]
Added: pypy/branch/cpython-extension/pypy/module/cpyext/thread.py
==============================================================================
--- (empty file)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/thread.py Thu Apr 29 00:52:55 2010
@@ -0,0 +1,8 @@
+
+from pypy.module.thread import os_thread
+from pypy.module.cpyext.api import CANNOT_FAIL, cpython_api
+from pypy.rpython.lltypesystem import rffi
+
+ at cpython_api([], rffi.LONG, error=CANNOT_FAIL)
+def PyThread_get_thread_ident(space):
+ return os_thread.get_ident(space)
More information about the Pypy-commit
mailing list