Opened 18 years ago
Closed 18 years ago
#4546 closed (fixed)
utils.datastructures.SortDict don't work after pop or popitem method called
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Core (Other) | Version: | |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
utils.datastructures.SortDict don't work after pop or popitem method called, here is example:
In [1]: from django.utils.datastructures import SortedDict
In [2]: s=SortedDict({1:2,3:4,2:3})
In [3]: s.popitem()
Out[3]: (1, 2)
In [4]: s.items()
---------------------------------------------------------------------------
exceptions.KeyError Traceback (most recent call last)
/home/glin/programming/workspace/nicms/<ipython console>
/usr/lib/python2.4/site-packages/django/utils/datastructures.py in items(self)
72
73 def items(self):
---> 74 return zip(self.keyOrder, self.values())
75
76 def keys(self):
/usr/lib/python2.4/site-packages/django/utils/datastructures.py in values(self)
78
79 def values(self):
---> 80 return [dict.__getitem__(self, k) for k in self.keyOrder]
81
82 def update(self, dict):
KeyError: 1
It is because pop and popitem methods are not overriden, so items in keyOrder attribute are not deleted.
Attachments (3)
Change History (8)
by , 18 years ago
| Attachment: | datastructures.py added |
|---|
comment:1 by , 18 years ago
by , 18 years ago
| Attachment: | datastructures.py.diff added |
|---|
comment:3 by , 18 years ago
| Has patch: | set |
|---|---|
| Needs tests: | set |
| Triage Stage: | Unreviewed → Accepted |
| Version: | newforms-admin |
Thanks, add some tests and it'll be ready
by , 18 years ago
| Attachment: | tests.py.diff added |
|---|
comment:5 by , 18 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
This was fixed as part of [6593].
Note:
See TracTickets
for help on using tickets.
Glin, could you please attach a diff instead of the whole file? Thanks.