Django

Code

Ticket #6611 (closed: fixed)

Opened 5 months ago

Last modified 5 months ago

SortedDict.copy breaks original dict if keys are added to copy

Reported by: jdunck Assigned to: nobody
Milestone: Component: Core framework
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Original problem:

>>> orig = SortedDict(data={"blah": 1, "huh": 2})
>>> orig
{'blah': 1, 'huh': 2}
>>> copy = orig.copy()
>>> copy["new_key"] = 3
>>> orig
<type 'exceptions.KeyError'>: 'new_key'

Attachments

sorteddict-copy-7121.diff (1.0 kB) - added by jdunck on 02/15/08 15:29:05.

Change History

02/15/08 15:29:05 changed by jdunck

  • attachment sorteddict-copy-7121.diff added.

02/15/08 15:30:20 changed by jdunck

The basic problem is that keyOrder is shared between the two dictionaries and adding keys to the copied dictionary make iteration of the original dictionary fail because keyOrder is extended without a corresponding entry being made in the original dictionary.

02/16/08 15:54:54 changed by Simon Greenhill <dev@simon.net.nz>

  • stage changed from Unreviewed to Ready for checkin.

02/18/08 17:08:51 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [7129]) Fixed #6611 -- When copying a SortedDict, make a new copy of the keys list. Thanks, Jeremy Dunck.


Add/Change #6611 (SortedDict.copy breaks original dict if keys are added to copy)




Change Properties
Action