[pypy-dev] debugging extension segfault

Laura Creighton lac at openend.se
Mon Nov 23 10:30:59 EST 2015


>> Lastly what is the right way to get the platform as pypy not cpython?
>> --
>> Robin Becker

Maciej already answered the other stuff.  I had pypy working with 
reportlab a long time ago just by not using the C extensions at all.

Detecting pypy is a bit harder.
https://www.python.org/dev/peps/pep-0421/#version-format
was supposed to fix things


lac at smartwheels:~$ python3.5
Python 3.5.0rc1 (default, Aug 12 2015, 14:57:46) 
[GCC 5.2.1 20150808] on linux
Type "help", "copyright", "credits" or "license" for more information.
 >>> import sys
 >>> sys.implementation
namespace(_multiarch='x86_64-linux-gnu', cache_tag='cpython-35', hexversion=50659521, name='cpython', version=sys.version_info(major=3, minor=5, micro=0, releaselevel='candidate', serial=1))
 >>> 

Okay, you could fish around in that and get what you are looking for.

But

Python 2.7.10 (default, Jul  1 2015, 10:54:53) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import sys
 >>> sys.implementation
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'implementation'

This won't.

So I just try to import __pypy__

If it succeeds, I have pypy, and if it doesn't I assume CPython.

Laura



More information about the pypy-dev mailing list