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.

classification
Title: can't deepcopy recursive new objects
Type: Stage:
Components: Interpreter Core Versions: Python 2.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, tim.peters
Priority: normal Keywords:

Created on 2001-12-28 21:29 by gvanrossum, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Messages (3)
msg8540 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2001-12-28 21:29
(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
msg8541 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2001-12-28 21:35
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.
msg8542 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2001-12-29 04:40
Logged In: YES 
user_id=31435

I'm sure Guido meant to close this.
History
Date User Action Args
2022-04-10 16:04:50adminsetgithub: 35843
2001-12-28 21:29:55gvanrossumcreate