Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#23594 closed Bug (fixed)

Deepcopy on ErrorDict shows unexpected duplicates

Reported by: Troy Grosfield Owned by: Tim Graham
Component: Forms Version: 1.7
Severity: Release blocker Keywords:
Cc: Loic Bistuer Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Using python 3.4, django 1.7, you'll see the following error when deepcopying ErrorDicts:

$ python
Python 3.4.1 (default, Aug 24 2014, 21:32:40)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from copy import deepcopy
>>> from django.forms.utils import ErrorList
>>> from django.forms.utils import ErrorDict
>>>
>>>
>>> ed = ErrorDict()
>>> ed['__all__'] = ErrorList(['first thing'])
>>> ed
{'__all__': ['first thing']}
>>> ed_copy = deepcopy(ed)
>>> ed_copy
{'__all__': ['first thing', 'first thing']}   # <-- what happened here? why is "first thing" listed twice?
>>> len(ed['__all__']) == len(ed_copy['__all__'])
False

Why did "first thing" get copied twice?

Attachments (1)

23594-test.diff (1.0 KB ) - added by Tim Graham 10 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 by Tim Graham, 10 years ago

Component: UncategorizedForms
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

Seems to be a regression from 1.6.

comment:2 by Tim Graham, 10 years ago

Owner: changed from nobody to Tim Graham
Status: newassigned

by Tim Graham, 10 years ago

Attachment: 23594-test.diff added

comment:3 by Tim Graham, 10 years ago

Bisected to 2fd7fc134cf0c0685ceac22fd858509aa43f819f. Regression test attached.

comment:5 by Loic Bistuer, 10 years ago

Cc: Loic Bistuer added
Has patch: set

comment:6 by Tim Graham, 10 years ago

Triage Stage: AcceptedReady for checkin

comment:7 by Loic Bistuer <loic.bistuer@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In ec2fd02bb3f9f7e732de1566e81f84637e29f161:

Fixed #23594 -- Fixed deepcopy on ErrorList.

Thanks Troy Grosfield for the report and Tim Graham for the tests.

comment:8 by Loic Bistuer <loic.bistuer@…>, 10 years ago

In 082abce81e48fe9397cce096e13d5199c99adfe9:

[1.7.x] Fixed #23594 -- Fixed deepcopy on ErrorList.

Thanks Troy Grosfield for the report and Tim Graham for the tests.

Backport of ec2fd02bb3 from master

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