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

Infinite recursion in pickling dynamically generated classes #229

Closed
robertwb opened this issue Jun 28, 2017 · 1 comment · Fixed by #443
Closed

Infinite recursion in pickling dynamically generated classes #229

robertwb opened this issue Jun 28, 2017 · 1 comment · Fixed by #443

Comments

@robertwb
Copy link
Contributor

Consider

def createB():       
     class B(object):
       def __init__(self):
         super(B, self).__init__()
     return B

Now dill.dumps(createB()) fails with an infinite loop of

T2: <class '__main__.B'>
D2: <dict object at 0x10ef5e050>
F1: <function __init__ at 0x10f075aa0>
D1: <dict object at 0x10e7ac050>
# D1
Ce: <cell at 0x10f013e88: type object at 0x7ff6a1d7cdb0>
T2: <class '__main__.B'>
...
@mmckerns
Copy link
Member

mmckerns commented Jul 6, 2017

I think this is very similar to #56, but I guess it looks like it's not a duplicate. Either way, the same error is thrown. Basically, dill can't find class B in the top-level namespace.

anivegesana added a commit to anivegesana/dill that referenced this issue Dec 11, 2021
anivegesana added a commit to anivegesana/dill that referenced this issue Dec 11, 2021
mmckerns pushed a commit that referenced this issue Jan 27, 2022
* Fix #229

* .get still fails when index is unhashable

* Cells are not allowed to change before 3.7

* Uncomment test cases if Python > 3.7

* Add more complex test case

* Spooky edits at a distance

* Wrap in exec to prevent syntax errors in Python 2

* Fix testcase

* Test impossible in Py2

* Small correction

* Correct the correction

* Add Python 2 support

* Turn feature on for Python 2

* Prefer function over object when possible

* Add changes from review

* Turn off test_circular_reference for Python 2

* Reformat and support empty cells

* Solve some more versioning issues

* Add shim that chooses the correct function at unpickling

* Avoid pickling dill._dill

* Small correction

* This is why dill._dill would try to pickle

* Add shim for reference cells

* Copy functions for sentinel

* Recursive function cells

* Turn on test case for Python 3 only

* Cell manipulation on PyPy 2.7

* Not possible in PyPy 2.7

* Correctly remove test case

* Fix coverage

* PyPy 2.7 Attempt 3

* Fix small issue

* Clean up _create_cell

* Empty cells in PyPy2

* Only two _create_cell functions

* Fixes from review

* Was probably not a good idea

They can probably implement it better for their own use-case or it can 
be added later.

* Split part of Shim into GetAttrShim

* Strange issue with exec in PyPy3.6

* Better _shims.py

* Rename cell_stack back to postproc

It is more flexible and allows for future plans in going to cPickle.

* Add _CELL_EMPTY to Python 3 in case it makes cPickle implementation easier

* Add postproc_list to _save_with_postproc

* Recursive functions and warnings

* Better warning messages

* Remove words "perfectly" and "would"
@mmckerns mmckerns added this to the dill-0.3.5 milestone Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants