Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#23492 closed Bug (fixed)

F objects are no longer deepcopy-able

Reported by: ris Owned by: nobody
Component: Database layer (models, ORM) Version: 1.7
Severity: Normal Keywords: F object expression deepcopy
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

I suspect the culprit is commit 3a66035107a640c4905f0a5f247a45f32dbe16d7 "Removed F.deepcopy()" because apparently "The method didn't change standard deepcopy in any way.".

Well, in 1.7.0:

>>> from django.db.models import F
>>> from copy import deepcopy
>>> f = F ( "something__some_field" )
>>> f.name
'something__some_field'
>>> g = deepcopy ( f )
>>> g.name
AttributeError: 'F' object has no attribute 'name'

Paste back in the same deepcopy method removed in 3a66035107a640c4905f0a5f247a45f32dbe16d7, and:

>>> from django.db.models import F
>>> from copy import deepcopy
>>> f = F ( "something__some_field" )
>>> f.name
'something__some_field'
>>> g = deepcopy ( f )
>>> g.name
'something__some_field'

Tadaa!

Can we have it back please?

Change History (5)

comment:1 by Baptiste Mispelon, 10 years ago

Triage Stage: UnreviewedAccepted

Hi,

I can indeed reproduce your issue and bisecting it points to 3a66035107a640c4905f0a5f247a45f32dbe16d7 as you suspected.

We should probably add the method back but also add some tests to make sure we don't break that again.

Thanks.

comment:2 by Baptiste Mispelon <bmispelon@…>, 10 years ago

Resolution: fixed
Status: newclosed

In d63ac5b595694c44ed8a64d782a177d2f92125d9:

Fixed #23492 -- Restored F.deepcopy.

This reverts commit 3a66035107a640c4905f0a5f247a45f32dbe16d7.
A regression test was also added.

comment:3 by Baptiste Mispelon <bmispelon@…>, 10 years ago

In 04e7c7d51f832407c49c3abb3413fbfbdb410f6f:

[1.7.x] Fixed #23492 -- Restored F.deepcopy.

This reverts commit 3a66035107a640c4905f0a5f247a45f32dbe16d7.
A regression test was also added.

Backport of d63ac5b595694c44ed8a64d782a177d2f92125d9 from master.

comment:4 by Tim Graham <timograham@…>, 10 years ago

In 92a8213fdbb6f7612847f3d803a9f91d0f9d6392:

Added 1.7.1 release notes for refs #23492.

comment:5 by Tim Graham <timograham@…>, 10 years ago

In 3f6430d084097082ea02a8e49ce3e28c7b75582c:

[1.7.x] Added 1.7.1 release notes for refs #23492.

Backport of 92a8213fdb from master

Note: See TracTickets for help on using tickets.
Back to Top