[py-svn] r34608 - py/dist/py/magic

arigo at codespeak.net arigo at codespeak.net
Tue Nov 14 18:58:46 CET 2006


Author: arigo
Date: Tue Nov 14 18:58:45 2006
New Revision: 34608

Modified:
   py/dist/py/magic/greenlet.py
Log:
Add support for using 'py.magic.greenlet' on programs that run on top of
a stackless pypy (you just get _stackless.greenlet, then).



Modified: py/dist/py/magic/greenlet.py
==============================================================================
--- py/dist/py/magic/greenlet.py	(original)
+++ py/dist/py/magic/greenlet.py	Tue Nov 14 18:58:45 2006
@@ -1,5 +1,10 @@
-
-import py
-gdir = py.path.local(py.__file__).dirpath() 
-path = gdir.join('c-extension', 'greenlet', 'greenlet.c')
-greenlet = path.getpymodule().greenlet 
+import sys
+if '_stackless' in sys.builtin_module_names:
+    # when running on top of a pypy with stackless support
+    from _stackless import greenlet
+else:
+    # regular CPython (or pypy without stackless support, and then crash :-)
+    import py
+    gdir = py.path.local(py.__file__).dirpath() 
+    path = gdir.join('c-extension', 'greenlet', 'greenlet.c')
+    greenlet = path.getpymodule().greenlet 



More information about the pytest-commit mailing list