Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CellType error when ctypes is unavailable #150

Closed
jasonmyers opened this issue Jan 28, 2016 · 2 comments
Closed

CellType error when ctypes is unavailable #150

jasonmyers opened this issue Jan 28, 2016 · 2 comments

Comments

@jasonmyers
Copy link
Contributor

Possibly related to #1 (not sure what the current status of appengine support is)

Using dill on appengine (python 2.7), where ctypes is unavailable (so triggers the HAS_CTYPES = False path)

Trying to pickle an in-line function that references a variable in the outer scope causes a cell error. Here is a reproducible case:

# Disable ctypes -- you could also just set HAS_CTYPES = False in dill.py
import ctypes
import sys
sys.modules['ctypes'] = None

import dill

def outer():
    x = 1

    def inner():
        x

    dill.loads(dill.dumps(inner))

outer()

Causes the following error:

  File "pickletest.py", line 11, in <module>
    outer()
  File "pickletest.py", line 9, in outer
    dill.loads(dill.dumps(inner))
  File ".../dill/dill.py", line 259, in loads
    return load(file)
  File ".../dill/dill.py", line 249, in load
    obj = pik.load()
  File ".../lib/python2.7/pickle.py", line 858, in load
    dispatch[key](self)
  File ".../lib/python2.7/pickle.py", line 1083, in load_newobj
    obj = cls.__new__(cls, *args)
TypeError: object.__new__(cell) is not safe, use cell.__new__()

Apologies if this is intentionally unsupported at the moment.

@jasonmyers
Copy link
Contributor Author

The above PR seems to fix the issue, but needs a sanity check

@mmckerns
Copy link
Member

mmckerns commented Feb 2, 2016

fixed by c38b68a

@mmckerns mmckerns modified the milestone: dill-0.2.5 Feb 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants