Django

Code

Ticket #3964 (closed: fixed)

Opened 2 years ago

Last modified 1 year ago

SortedDict string representation not in order of keys

Reported by: forest@alittletooquiet.net Assigned to: jacob
Milestone: Component: Uncategorized
Version: SVN Keywords: SortedDict __repr__ repr
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 1 Patch needs improvement: 0

Description

This is more-or-less a problem with Python's dict implementation, IMO. It's really nothing more than a convenience thing, but for SortedDict, repr(d) doesn't indicate the proper key order. It seems that the standard dict.repr does not iterate over the dict like I would expect it to.

Attached is a patch that re-implements repr using an iterator over the object. Thus, SortedDict's are displayed properly in the Python shell.

Attachments

SortedDict__repr__.diff (0.7 kB) - added by Forest Bond <forest@alittletooquiet.net> on 04/08/07 09:30:56.
patch implementing SortedDict.repr

Change History

04/08/07 09:30:56 changed by Forest Bond <forest@alittletooquiet.net>

  • attachment SortedDict__repr__.diff added.

patch implementing SortedDict.repr

04/11/07 05:40:20 changed by Simon G. <dev@simon.net.nz>

  • needs_better_patch changed.
  • stage changed from Unreviewed to Ready for checkin.
  • needs_tests changed.
  • needs_docs changed.

04/12/07 08:28:09 changed by russellm

  • needs_tests set to 1.

04/25/07 02:30:54 changed by mtredinnick

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

(In [5069]) Fixed #3964 -- Added a custom SortedDict.repr so that the keys are printed in sorted order. Based on a patch from Forest Bond.


Add/Change #3964 (SortedDict string representation not in order of keys)




Change Properties
Action