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.

classification
Title: json module skipkeys handling changed exception types in 2.7
Type: behavior Stage: commit review
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, bob.ippolito, doughellmann, eric.araujo, pitrou, r.david.murray, ysj.ray
Priority: normal Keywords: patch

Created on 2010-07-18 15:48 by doughellmann, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
json_skipkeys.py doughellmann, 2010-07-18 15:57
json_trunk.diff ysj.ray, 2010-07-20 04:00 patch against the trunk.
json_py3k.diff ysj.ray, 2010-07-20 04:00 patch against py3k
Messages (12)
msg110660 - (view) Author: Doug Hellmann (doughellmann) * (Python committer) Date: 2010-07-18 15:48
Under Python 2.6 the json encoder raised a TypeError when it encountered dictionary keys that were not strings.  Under 2.7, that exception has changed to a ValueError, but the documentation still says it raises TypeError.  I'm not sure which is right, but TypeError seems like the correct exception.
msg110661 - (view) Author: Doug Hellmann (doughellmann) * (Python committer) Date: 2010-07-18 15:57
The attached file json_skipkeys.py illustrates the problem.
msg110663 - (view) Author: Doug Hellmann (doughellmann) * (Python committer) Date: 2010-07-18 16:14
Looking into the code, I see in _json.c that a ValueError is raised by encoder_listencode_dict() on line 2150, but in the pure-Python implementation in json/encoder.py a TypeError is raised by _make_iterencode() on line 376.
msg110749 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-07-19 13:38
Adding some people to nosy: Bob, who wrote the code, and Antoine and Benjamin who were involved in the update and probably have an opinion on the correct fix.

(c.f.: Issue4136)
msg110754 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-07-19 13:50
TypeError sounds right indeed. Patches welcome (even better with tests).
msg110756 - (view) Author: Doug Hellmann (doughellmann) * (Python committer) Date: 2010-07-19 13:55
Bob fixed this in simplejson under ticket 82 (http://code.google.com/p/simplejson/issues/detail?id=82).
msg110861 - (view) Author: ysj.ray (ysj.ray) Date: 2010-07-20 04:00
I worked out two patches, one for trunk and one for py3k, both with tests, hope someone could do a reviewing.
msg110884 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-07-20 11:04
A quick look suggests that the patches are ok, thank you.
msg110946 - (view) Author: Doug Hellmann (doughellmann) * (Python committer) Date: 2010-07-20 18:50
Ray, thanks for the patches.  Antoine, I appreciate the review.  I'll try to get these checked in to svn in the next day or two.  

I see that this ticket is tagged as related to versions 2.7, 3.1, and 3.2.  Should the changes be applied to any branches other than trunk and py3k?
msg110952 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-07-20 19:05
> Should the changes be applied to any branches other than trunk and py3k?

release31-maint.
msg110972 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-07-20 20:54
I believe there are no commits on trunk. Affected branches are py3k and release{27,31}-maint IIUC.
msg111042 - (view) Author: Doug Hellmann (doughellmann) * (Python committer) Date: 2010-07-21 12:36
Committed to py3k as r83016, release31-maint as r83017, and release27-maint as r83018.

Thanks for your help, everyone.
History
Date User Action Args
2022-04-11 14:57:03adminsetgithub: 53542
2010-07-21 12:36:54doughellmannsetstatus: open -> closed
resolution: fixed
messages: + msg111042
2010-07-20 20:54:02eric.araujosetnosy: + eric.araujo
messages: + msg110972
2010-07-20 19:05:40pitrousetmessages: + msg110952
2010-07-20 18:50:59doughellmannsetmessages: + msg110946
2010-07-20 11:04:00pitrousetmessages: + msg110884
stage: needs patch -> commit review
2010-07-20 04:00:41ysj.raysetfiles: + json_py3k.diff
2010-07-20 04:00:11ysj.raysetfiles: + json_trunk.diff

nosy: + ysj.ray
messages: + msg110861

keywords: + patch
2010-07-19 13:55:41doughellmannsetmessages: + msg110756
2010-07-19 13:50:31pitrousetstage: test needed -> needs patch
messages: + msg110754
versions: + Python 3.1, Python 3.2
2010-07-19 13:38:34r.david.murraysetnosy: + r.david.murray, pitrou, bob.ippolito, benjamin.peterson

messages: + msg110749
stage: test needed
2010-07-18 16:14:17doughellmannsetmessages: + msg110663
2010-07-18 15:57:09doughellmannsetfiles: + json_skipkeys.py

messages: + msg110661
2010-07-18 15:48:55doughellmanncreate