[issue17368] Python version of JSON decoder does not work with object_pairs_hook

2013-03-12 Thread Ezio Melotti

Ezio Melotti added the comment:

Fixed.  I used OrderedDict to make sure that the object hook is actually used.

--
resolution:  -> fixed
stage: patch review -> committed/rejected
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17368] Python version of JSON decoder does not work with object_pairs_hook

2013-03-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 4a5ad099b176 by Ezio Melotti in branch '2.7':
#17368: Fix an off-by-one error in the Python JSON decoder that caused a 
failure while decoding empty object literals when object_pairs_hook was 
specified.
http://hg.python.org/cpython/rev/4a5ad099b176

New changeset 40c36d873f41 by Ezio Melotti in branch '3.2':
#17368: Fix an off-by-one error in the Python JSON decoder that caused a 
failure while decoding empty object literals when object_pairs_hook was 
specified.
http://hg.python.org/cpython/rev/40c36d873f41

New changeset dd2fad6b47c0 by Ezio Melotti in branch '3.3':
#17368: merge with 3.2.
http://hg.python.org/cpython/rev/dd2fad6b47c0

New changeset 885ffda21849 by Ezio Melotti in branch 'default':
#17368: merge with 3.3.
http://hg.python.org/cpython/rev/885ffda21849

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17368] Python version of JSON decoder does not work with object_pairs_hook

2013-03-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

LGTM. Perhaps with object_pairs_hook=tuple or object_pairs_hook=dict this test 
will look simpler.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17368] Python version of JSON decoder does not work with object_pairs_hook

2013-03-11 Thread Ezio Melotti

Ezio Melotti added the comment:

Here's a patch.

--
assignee:  -> ezio.melotti
keywords: +patch
stage: test needed -> patch review
Added file: http://bugs.python.org/file29384/issue17368.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17368] Python version of JSON decoder does not work with object_pairs_hook

2013-03-06 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti, serhiy.storchaka
stage:  -> test needed
type:  -> behavior
versions:  -Python 3.1, Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17368] Python version of JSON decoder does not work with object_pairs_hook

2013-03-06 Thread R. David Murray

R. David Murray added the comment:

Both the Python version and the C version are supposed to be subject to the 
same tests (at least in Python3, I don't remember the state of things in 2.7), 
so this probably indicates there is a missing test for this case.  Do you have 
any interest in trying your hand at writing one?  The tests are in 
Lib/test/json_tests in Python3.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17368] Python version of JSON decoder does not work with object_pairs_hook

2013-03-06 Thread Aki

New submission from Aki:

Specifying any object_pairs_hook makes JSON decoding break when JSONObject from 
json/decoder.py is used.

Can be emulated easily by setting c_make_scanner = None at json/scanner.py

Example script:
**
import json
test = '{"key": "value", "empty": {}}'

def hook(pairs):
return dict(pairs)

print(json.loads(test, object_pairs_hook=hook))
**

This test will fail because the return statement on line 166 in 
http://hg.python.org/cpython/file/cfc777407b03/Lib/json/decoder.py lacks "+ 1" 
even though the statement on line 170 has it. Basically, any empty JSON object 
will cause "ValueError: Extra data: [...]".

--
components: Library (Lib)
messages: 183600
nosy: Kuukunen
priority: normal
severity: normal
status: open
title: Python version of JSON decoder does not work with object_pairs_hook
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com