Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue14692] json.joads parse_constant callback not working anymore

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Apr 29, 2012, 3:34 AM

Post #1 of 7 (57 views)
Permalink
[issue14692] json.joads parse_constant callback not working anymore

New submission from Jakob Simon-Gaarde <jakobsg [at] gmail>:

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

----------
components: Extension Modules
files: test_parse_constant.py
messages: 159596
nosy: Jakob.Simon-Gaarde
priority: normal
severity: normal
status: open
title: json.joads parse_constant callback not working anymore
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file25405/test_parse_constant.py

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14692>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Apr 29, 2012, 3:38 AM

Post #2 of 7 (54 views)
Permalink
[issue14692] json.joads parse_constant callback not working anymore [In reply to]

Changes by Ezio Melotti <ezio.melotti [at] gmail>:


----------
nosy: +ezio.melotti
stage: -> needs patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14692>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Apr 29, 2012, 4:21 AM

Post #3 of 7 (56 views)
Permalink
[issue14692] json.joads parse_constant callback not working anymore [In reply to]

Serhiy Storchaka <storchaka [at] gmail> added the comment:

This behavior was changed in changeset f686aced02a3 three year ago. If this change is intentional, then you need edit documentation.

----------
nosy: +storchaka

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14692>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Apr 29, 2012, 4:25 AM

Post #4 of 7 (58 views)
Permalink
[issue14692] json.joads parse_constant callback not working anymore [In reply to]

Hynek Schlawack <hs [at] ox> added the comment:

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.

----------
assignee: -> docs [at] pytho
components: +Documentation -Extension Modules
nosy: +docs [at] pytho, eric.araujo, georg.brandl, hynek
versions: +Python 3.2, Python 3.3

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14692>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Apr 29, 2012, 4:33 AM

Post #5 of 7 (53 views)
Permalink
[issue14692] json.joads parse_constant callback not working anymore [In reply to]

Changes by Serhiy Storchaka <storchaka [at] gmail>:


----------
keywords: +patch
Added file: http://bugs.python.org/file25406/json_parse_constant_doc.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14692>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Apr 29, 2012, 5:51 AM

Post #6 of 7 (52 views)
Permalink
[issue14692] json.joads parse_constant callback not working anymore [In reply to]

Ezio Melotti <ezio.melotti [at] gmail> added the comment:

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

----------
nosy: +rhettinger

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14692>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Apr 30, 2012, 2:54 AM

Post #7 of 7 (48 views)
Permalink
[issue14692] json.joads parse_constant callback not working anymore [In reply to]

Jakob Simon-Gaarde <jakobsg [at] gmail> added the comment:

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

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14692>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.