msg159596 - (view) |
Author: Jakob Simon-Gaarde (Jakob.Simon-Gaarde) |
Date: 2012-04-29 10:34 |
Hi It seems like the parse_constant keyword parameter for registering a callback function is no longer called in Python 2.7. http://docs.python.org/library/json.html#json.load I am using Python 2.7.3 on Ubuntu 12.04 I have created and attached a script that shows the problem. Output in Python 2.6: Met an int! Met a constant! {u'a': None, u'b': None} Output in Python 2.7: Met an int! {u'a': None, u'b': False} So parse_int callback still works btw. Best Regards Jakob Simon-Gaarde |
|
|
msg159600 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2012-04-29 11:21 |
This behavior was changed in changeset f686aced02a3 three year ago. If this change is intentional, then you need edit documentation. |
|
|
msg159601 - (view) |
Author: Hynek Schlawack (hynek) *  |
Date: 2012-04-29 11:25 |
Hi Jakob, parse_constant has been changed as of d95e5add3ca4 to be called only on "-Infinity, Infinity, NaN": ``parse_constant``, if specified, will be called with one of the following strings: -Infinity, Infinity, NaN. This can be used to raise an exception if invalid JSON numbers are encountered. And indeed, if you change your example to Infinity, it gets called. That said, neither the 2.7 nor the dev docs reflect that. So it seems like a documentation bug to me. |
|
|
msg159604 - (view) |
Author: Ezio Melotti (ezio.melotti) *  |
Date: 2012-04-29 12:51 |
The original changeset is at [0], and the commit message just says "even more decoder optimizations". The official website[1] and the RFC[2] don't list any constant, so I guess the definition of what a constant is is not well defined. [0]: http://code.google.com/p/simplejson/source/detail?spec=svn103&r=103 [1]: http://www.json.org/ [2]: http://tools.ietf.org/html/rfc4627 |
|
|
msg159685 - (view) |
Author: Jakob Simon-Gaarde (Jakob.Simon-Gaarde) |
Date: 2012-04-30 09:54 |
Ok, I accept that at some point it was decided to take away the call to parse_constant hook on "true" and "false" values. But how does it help me to know this, I still need to react on these values? It seems a little overkill to parse through all parsed values using object_pairs_hook. Best Regards Jakob Simon-Gaarde |
|
|
msg160846 - (view) |
Author: Hynek Schlawack (hynek) *  |
Date: 2012-05-16 12:25 |
I'm afraid I have to close this one as rejected. It works as documented and it's unlikely we'll decide to change it back. I'm sorry. |
|
|
msg160862 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2012-05-16 13:44 |
> I'm afraid I have to close this one as rejected. It works as documented and it's unlikely we'll decide to change it back. I'm sorry. It does not work as documented. The proposed patch fixes the documentation. |
|
|
msg160868 - (view) |
Author: Hynek Schlawack (hynek) *  |
Date: 2012-05-16 14:18 |
You're right, I was referring to the doc string. |
|
|
msg160889 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2012-05-16 17:10 |
New changeset 30d16d1e5175 by Hynek Schlawack in branch '2.7': #14692 Fix json docs to reflect changes in json.load http://hg.python.org/cpython/rev/30d16d1e5175 New changeset 4f27c4dc34ed by Hynek Schlawack in branch '3.2': #14692 Fix json docs to reflect changes in json.load http://hg.python.org/cpython/rev/4f27c4dc34ed New changeset 0f6a6f59b002 by Hynek Schlawack in branch 'default': #14692 Fix json docs to reflect changes in json.load http://hg.python.org/cpython/rev/0f6a6f59b002 |
|
|
msg160890 - (view) |
Author: Hynek Schlawack (hynek) *  |
Date: 2012-05-16 17:11 |
Thanks Serhiy! |
|
|