[Python-bugs-list] [ python-Bugs-592567 ] Bug with deepcopy and new style objects

noreply@sourceforge.net noreply@sourceforge.net
Mon, 12 Aug 2002 13:22:16 -0700


Bugs item #592567, was opened at 2002-08-08 08:42
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=592567&group_id=5470

Category: Type/class unification
Group: Python 2.2.1
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Jiba (jiba)
Assigned to: Guido van Rossum (gvanrossum)
Summary: Bug with deepcopy and new style objects

Initial Comment:
Deepcopying new style objects can bug if more than one
of such objects are deep copied at the same time (E.g.
you are deepcopying a list of two new style objects).

It seems that , in copy._reconstruct, the "state" 
variable should be "kept alive" (by passing it to the
"_keep_alive" function), since this state may be gc'ed,
and another state may be created later with the same
address memory / ID.

BTW, the same problem may arise with the "args"
variable, in the same function.

The included file demonstrates the bug.

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

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-08-12 16:22

Message:
Logged In: YES 
user_id=6380

Fixed in CVS, both for Python 2.3 and 2.2.2, using your
proposed patch (with a different comment). Thanks!

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

Comment By: Jiba (jiba)
Date: 2002-08-12 15:03

Message:
Logged In: YES 
user_id=591223

I have just submitted a patch for fixing this bug -- the
patch uses an alternative solution to the one i explained
above; i would prefer the patch to the above solution.

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

Comment By: Raymond Hettinger (rhettinger)
Date: 2002-08-08 23:43

Message:
Logged In: YES 
user_id=80475

Confirmed on 2.2.1 and 2.3a:

Before deepcopying :
[11, 12, 13]
[21, 22, 23]
[31, 32, 33]

After deepcopying :
[11, 12, 13]
[11, 12, 13]
[11, 12, 13]


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

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