#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 , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
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.