Opened 13 years ago

Closed 13 years ago

#18175 closed Bug (fixed)

SortedDict issue when copied with copy.copy

Reported by: linovia Owned by: nobody
Component: Uncategorized Version: 1.4
Severity: Normal Keywords:
Cc: linovia Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If SortedDict is copied using the copy.copy, the data are duplicated.

>>> from django.utils.datastructures import SortedDict
>>> from copy import copy
>>> test = SortedDict()
>>> test['a']=1
>>> copy(test)
{'a': 1, 'a': 1}
>>> test
{'a': 1, 'a': 1}

You'll find joined a test patch to show this issue.

Attachments (3)

failing_sorted_dict_test.diff (622 bytes ) - added by linovia 13 years ago.
Failing test case
sorted_dict_copy.diff (1.1 KB ) - added by linovia 13 years ago.
sorted_dict_copy_2.diff (1.2 KB ) - added by linovia 13 years ago.
Test & patch with a comment

Download all attachments as: .zip

Change History (6)

by linovia, 13 years ago

Failing test case

by linovia, 13 years ago

Attachment: sorted_dict_copy.diff added

comment:1 by linovia, 13 years ago

Cc: linovia added
Has patch: set

Here's the patch.

comment:2 by Anssi Kääriäinen, 13 years ago

Can you explain what is going wrong currently? Why that __copy__ method is needed? Preferably in a comment included in the patch.

by linovia, 13 years ago

Attachment: sorted_dict_copy_2.diff added

Test & patch with a comment

comment:3 by Anssi Kääriäinen, 13 years ago

Resolution: fixed
Status: newclosed
Triage Stage: UnreviewedAccepted

Fixed in commit 4b11762f7d7aed2f4f36c4158326c0a4332038f9

I did some small changes to the patch. I still don't understand why the behavior was broken before.

Thanks for the report & patch!

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