msg110660 - (view) |
Author: Doug Hellmann (doughellmann) *  |
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) *  |
Date: 2010-07-18 15:57 |
The attached file json_skipkeys.py illustrates the problem. |
|
|
msg110663 - (view) |
Author: Doug Hellmann (doughellmann) *  |
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) *  |
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) *  |
Date: 2010-07-19 13:50 |
TypeError sounds right indeed. Patches welcome (even better with tests). |
|
|
msg110756 - (view) |
Author: Doug Hellmann (doughellmann) *  |
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) *  |
Date: 2010-07-20 11:04 |
A quick look suggests that the patches are ok, thank you. |
|
|
msg110946 - (view) |
Author: Doug Hellmann (doughellmann) *  |
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) *  |
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) *  |
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) *  |
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. |
|
|