This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jedwards
Recipients Aaron Hall, jedwards, josh.r, r.david.murray, tanzer@swing.co.at, zachrahan
Date 2018-06-29.07:08:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1530256121.3.0.56676864532.issue25457@psf.upfronthosting.co.za>
In-reply-to
Content
This came up in a StackOverflow question[1] today, so I took a stab at addressing the error.  The changes don't restore the 2.x behavior, but just do as R. David Murray suggested and coerce the keys to strings prior to sorting to prevent the error.

The changes in _json.c and json.decoder are handled slightly differently in the case of skipkeys.

Both create a list of (coerced_key, value) pairs, sorts it (when specified), and uses that in place of the PyDict_Items / .items().

When skipkeys=True and invalid (uncoercible) keys are found, the c code will just not append that item to the coerced_items list while the python code uses None to signal that item should be filtered out.

(That being said, I'm not a huge fan of the approach I used in the Python code and may rewrite using .append instead of a generator.

The c code could definitely use a review when it comes to reference counts.

Fork commit: https://github.com/jheiv/cpython/commit/8d3612f56a137da0d26b83d00507ff2f11bca9bb

[1] https://stackoverflow.com/questions/51093268/why-am-i-getting-typeerror-unorderable-types-str-int-in-this-code
History
Date User Action Args
2018-06-29 07:08:41jedwardssetrecipients: + jedwards, zachrahan, r.david.murray, josh.r, tanzer@swing.co.at, Aaron Hall
2018-06-29 07:08:41jedwardssetmessageid: <1530256121.3.0.56676864532.issue25457@psf.upfronthosting.co.za>
2018-06-29 07:08:41jedwardslinkissue25457 messages
2018-06-29 07:08:40jedwardscreate