Skip to content

Commit

Permalink
added HAS_PYTHONAPI for compatibilty with newer versions of pypy
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://svn.mystic.cacr.caltech.edu/pathos/dill@732 8bfda07e-5b16-0410-ab1d-fd04ec2748df
  • Loading branch information
mmckerns committed Jan 13, 2015
1 parent e023165 commit 07497f7
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions dill/dill.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ def _trace(boolean):
try:
import ctypes
HAS_CTYPES = True
HAS_PYTHONAPI = True
except ImportError:
HAS_CTYPES = False
HAS_PYTHONAPI = False
try:
from numpy import ufunc as NumpyUfuncType
from numpy import ndarray as NumpyArrayType
Expand Down Expand Up @@ -524,12 +526,16 @@ def __getattribute__(self, attr):
attrs[index] = ".".join([attrs[index], attr])
return type(self)(attrs, index)

if HAS_CTYPES:
ctypes.pythonapi.PyCell_New.restype = ctypes.py_object
ctypes.pythonapi.PyCell_New.argtypes = [ctypes.py_object]
# thanks to Paul Kienzle for cleaning the ctypes CellType logic
def _create_cell(contents):
return ctypes.pythonapi.PyCell_New(contents)
if HAS_CTYPES and HAS_PYTHONAPI:
try: # if using `pypi`, pythonapi is not found
ctypes.pythonapi.PyCell_New.restype = ctypes.py_object
ctypes.pythonapi.PyCell_New.argtypes = [ctypes.py_object]
# thanks to Paul Kienzle for cleaning the ctypes CellType logic
def _create_cell(contents):
return ctypes.pythonapi.PyCell_New(contents)

except AttributeError:
HAS_PYTHONAPI = False

def _create_weakref(obj, *args):
from weakref import ref
Expand Down Expand Up @@ -819,7 +825,7 @@ def save_wrapper_descriptor(pickler, obj):
obj.__repr__()), obj=obj)
return

if HAS_CTYPES:
if HAS_CTYPES and HAS_PYTHONAPI:
@register(CellType)
def save_cell(pickler, obj):
log.info("Ce: %s" % obj)
Expand Down

0 comments on commit 07497f7

Please sign in to comment.