Opened 9 years ago

Closed 9 years ago

#3964 closed (fixed)

SortedDict string representation not in order of keys

Reported by: forest@… Owned by: jacob
Component: Uncategorized Version: master
Severity: Keywords: SortedDict __repr__ repr
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:


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 (1)

SortedDict__repr__.diff (713 bytes) - added by Forest Bond <forest@…> 9 years ago.
patch implementing SortedDict.repr

Download all attachments as: .zip

Change History (4)

Changed 9 years ago by Forest Bond <forest@…>

patch implementing SortedDict.repr

comment:1 Changed 9 years ago by Simon G. <dev@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Ready for checkin

comment:2 Changed 9 years ago by russellm

  • Needs tests set

comment:3 Changed 9 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(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.

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