This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2004年07月27日 20:55 by skip.montanaro, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| picklecycle.py | skip.montanaro, 2004年07月27日 20:55 | |||
| memoize.py | skip.montanaro, 2004年07月27日 20:56 | |||
| cycle.out | skip.montanaro, 2004年07月27日 20:57 | |||
| picklecycle3.py | belopolsky, 2010年07月15日 03:54 | |||
| Messages (8) | |||
|---|---|---|---|
| msg21827 - (view) | Author: Skip Montanaro (skip.montanaro) * (Python triager) | Date: 2004年07月27日 20:55 | |
The attached script (picklecycle.py) gives me an assertion error in Pickler.memoize(). Maybe I'm just doing something dumb. I have very little experience with pickle and even less experience pickling new-style class instances. I'm just trying to adapt an existing messy object graph to allow it to be pickled. I realize the two instances refer to each other, but I thought pickle was supposed to gracefully handle cyclic object graphs. I can worm around the problem a couple ways. First, getting rid of new-style classes does the trick. Also modifying B.__reduce__ to not return self.__dict__ seems to do the trick. Output (cycle.out) and a modified version of Pickler.memoize (memoize.py) will be attached momentarily. |
|||
| msg21828 - (view) | Author: Skip Montanaro (skip.montanaro) * (Python triager) | Date: 2004年07月27日 20:56 | |
Logged In: YES user_id=44345 Attaching chatty version of Pickler.memoize() |
|||
| msg21829 - (view) | Author: Skip Montanaro (skip.montanaro) * (Python triager) | Date: 2004年07月27日 20:57 | |
Logged In: YES user_id=44345 Attaching the output I see when running picklecycle.py w/ the modified memoize() method (cycle.out). |
|||
| msg21830 - (view) | Author: engelbert gruber (grubert) * | Date: 2005年05月19日 11:00 | |
Logged In: YES user_id=147070 it does memoize recursively, but "asserts" not to get stuck in cycles. that's how i understand the code if :: assert id(obj) not in self.memo is replaced by :: if id(obj) in self.memo: return it works (better). and test_pickle.py still passes. |
|||
| msg77200 - (view) | Author: mike bayer (zzzeek) * | Date: 2008年12月07日 01:03 | |
This bug can be reproduced very easily: import pickle class MyClass(object): pass m = MyClass() m2 = MyClass() s = set([m]) m.foo = set([m2]) m2.foo = s print pickle.dumps(s) This bug is critical as the pure-python pickle module is required when trying to remove warnings in -3 mode with Python 2.6, which is something that will be very common in the near future. It's easily reproducible with simplistic object cycles like that of the above, in 2.5, 2.6 and 3.0 at least. |
|||
| msg88576 - (view) | Author: mike bayer (zzzeek) * | Date: 2009年05月30日 19:07 | |
im noticing my test case seems to work fine in py 3.0.1. haven't tested 2.6.2. |
|||
| msg110343 - (view) | Author: Alexander Belopolsky (belopolsky) * (Python committer) | Date: 2010年07月15日 03:54 | |
This looks like a duplicate of issue 1581183. The issue is still present in py3k, but only shows up in picklecycle.py when using pickle.py version. I am attaching picklecycle3.py which is py3k version of picklecycle.py using python pickler. |
|||
| msg110400 - (view) | Author: Alexander Belopolsky (belopolsky) * (Python committer) | Date: 2010年07月15日 23:10 | |
There are two issues here. The original issue is a duplicate of #1062277. The other issue is specific to cycles containing a set. [msg77200] I am opening a separate issue for that. See #9269. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:06 | admin | set | github: 40652 |
| 2010年08月16日 20:02:38 | belopolsky | set | status: pending -> closed |
| 2010年07月15日 23:10:13 | belopolsky | set | status: open -> pending resolution: duplicate superseder: Cannot pickle self-referencing sets messages: + msg110400 |
| 2010年07月15日 03:54:06 | belopolsky | set | files:
+ picklecycle3.py type: behavior assignee: belopolsky versions: + Python 3.2 nosy: + alexandre.vassalotti, belopolsky messages: + msg110343 stage: needs patch |
| 2010年05月20日 20:30:12 | skip.montanaro | set | nosy:
- skip.montanaro |
| 2009年05月30日 19:07:04 | zzzeek | set | messages: + msg88576 |
| 2008年12月07日 01:03:34 | zzzeek | set | nosy:
+ zzzeek messages: + msg77200 |
| 2008年03月14日 17:42:36 | schmir | set | nosy: + schmir |
| 2004年07月27日 20:55:41 | skip.montanaro | create | |