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.
Created on 2012年04月29日 10:34 by Jakob.Simon-Gaarde, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| test_parse_constant.py | Jakob.Simon-Gaarde, 2012年04月29日 10:34 | |||
| json_parse_constant_doc.patch | serhiy.storchaka, 2012年04月29日 11:33 | review | ||
| Messages (10) | |||
|---|---|---|---|
| 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) * (Python committer) | 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) * (Python committer) | 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) * (Python committer) | 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) * (Python committer) | 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) * (Python committer) | 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) * (Python committer) | Date: 2012年05月16日 14:18 | |
You're right, I was referring to the doc string. |
|||
| msg160889 - (view) | Author: Roundup Robot (python-dev) (Python triager) | 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) * (Python committer) | Date: 2012年05月16日 17:11 | |
Thanks Serhiy! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:29 | admin | set | github: 58897 |
| 2012年05月16日 17:11:57 | hynek | set | status: open -> closed resolution: fixed messages: + msg160890 stage: patch review -> resolved |
| 2012年05月16日 17:10:36 | python-dev | set | nosy:
+ python-dev messages: + msg160889 |
| 2012年05月16日 14:18:51 | hynek | set | status: closed -> open resolution: rejected -> (no value) messages: + msg160868 stage: resolved -> patch review |
| 2012年05月16日 13:44:04 | serhiy.storchaka | set | messages: + msg160862 |
| 2012年05月16日 12:25:10 | hynek | set | status: open -> closed resolution: rejected messages: + msg160846 stage: needs patch -> resolved |
| 2012年05月04日 18:06:52 | terry.reedy | set | title: json.joads parse_constant callback not working anymore -> json.loads parse_constant callback not working anymore |
| 2012年04月30日 09:54:45 | Jakob.Simon-Gaarde | set | messages: + msg159685 |
| 2012年04月29日 12:51:24 | ezio.melotti | set | nosy:
+ rhettinger messages: + msg159604 |
| 2012年04月29日 11:33:53 | serhiy.storchaka | set | files:
+ json_parse_constant_doc.patch keywords: + patch |
| 2012年04月29日 11:25:04 | hynek | set | versions:
+ Python 3.2, Python 3.3 nosy: + hynek, eric.araujo, georg.brandl, docs@python messages: + msg159601 assignee: docs@python components: + Documentation, - Extension Modules |
| 2012年04月29日 11:21:26 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg159600 |
| 2012年04月29日 10:38:49 | ezio.melotti | set | nosy:
+ ezio.melotti stage: needs patch |
| 2012年04月29日 10:34:25 | Jakob.Simon-Gaarde | create | |