[Python-bugs-list] [ python-Bugs-497426 ] can't deepcopy recursive new objects

noreply@sourceforge.net noreply@sourceforge.net
Fri, 28 Dec 2001 13:35:22 -0800


Bugs item #497426, was opened at 2001-12-28 13:29
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=497426&group_id=5470

Category: Type/class unification
>Group: Python 2.2.1 candidate
Status: Open
>Resolution: Fixed
Priority: 5
Submitted By: Guido van Rossum (gvanrossum)
Assigned to: Guido van Rossum (gvanrossum)
Summary: can't deepcopy recursive new objects

Initial Comment:
(This was reported on c.l.py by Oliver Hartman, using a
more elaborate example.)

Take this simple recursive data structure:

| class Node(object):
|     pass
| a = Node(); b = Node()
| a.b = b; b.a = a
| import copy
| c = copy.deepcopy(a)

This raises RuntimeError: maximum recursion depth
exceeded


----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-12-28 13:35

Message:
Logged In: YES 
user_id=6380

Cause: The code in deepcopy() and _reconstruct() was naive
-- they didn't pass the memo to each other.

I've checked in a fix as copy.py rev. 1.23.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=497426&group_id=5470