[issue4785] json.JSONDecoder() strict argument undocumented and potentially confusing

2010-10-15 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Thanks, applied in r85543 and r85544.

--
resolution:  - fixed
status: open - closed

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



[issue4785] json.JSONDecoder() strict argument undocumented and potentially confusing

2010-06-05 Thread Tal Einat

Tal Einat talei...@users.sourceforge.net added the comment:

Documentation patch attached against py3k branch.

Changes are:

* Added to documentation of JSONDecoder:

If *strict* is ``False`` (``True`` is the default), then control characters 
will be allowed inside strings.  Control characters in this context are those 
with character codes in the 0-31 range, including ``'\t'`` (tab), ``'\n'``, 
``'\r'`` and ``'\0'``.

* Added clarification in documentation of json.load and json.dump that unless 
the cls kwarg is specified, the JSONEncoder/JSONDecoder class will be used.

* Mirrored these additions in the relevant doc-strings (JSONDecoder.__init__, 
json.load, json.loads, json.dump, json.dumps).

* Copied description of the object_pairs_hook kwargs from the documentation to 
the relevant doc-strings, which otherwise fully mirrored the documentation. 
(json.load, json.loads, JSONDecoder.__init__)

--
keywords: +patch
versions: +Python 3.2 -Python 2.6, Python 3.0
Added file: http://bugs.python.org/file17560/json_docs_py3k.diff

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



[issue4785] json.JSONDecoder() strict argument undocumented and potentially confusing

2010-06-05 Thread Tal Einat

Tal Einat talei...@users.sourceforge.net added the comment:

Similar patch against trunk; same changes as for the py3k branch.

--
Added file: http://bugs.python.org/file17561/json_docs_trunk.diff

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



[issue4785] json.JSONDecoder() strict argument undocumented and potentially confusing

2010-06-05 Thread Tal Einat

Changes by Tal Einat talei...@users.sourceforge.net:


--
versions: +Python 2.7

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



[issue4785] json.JSONDecoder() strict argument undocumented and potentially confusing

2010-06-04 Thread Tal Einat

Tal Einat talei...@users.sourceforge.net added the comment:

This goes down into _json.scanstring. Looking at the C code for 
scanstring_unicode, the strict parameter allow control characters inside 
strings: if strict is zero then literal control characters are allowed. From 
the code itself (current py3k head, r81032), it seems this means any character 
= 0x1f. See scanstring_unicode in 
http://svn.python.org/view/python/branches/py3k/Modules/_json.c?revision=81032view=markup
 for details.

Documentation should be updated accordingly.

--
nosy: +taleinat

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



[issue4785] json.JSONDecoder() strict argument undocumented and potentially confusing

2010-06-04 Thread Tal Einat

Tal Einat talei...@users.sourceforge.net added the comment:

This goes down into _json.scanstring. Looking at the C code for 
scanstring_unicode, strict=False allows control characters inside strings: if 
strict is zero then literal control characters are allowed. From the code 
itself (current py3k head, r81032), it seems this means any character = 0x1f. 
See scanstring_unicode in 
http://svn.python.org/view/python/branches/py3k/Modules/_json.c?revision=81032view=markup
 for details.

Documentation should be updated accordingly.

--

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



[issue4785] json.JSONDecoder() strict argument undocumented and potentially confusing

2008-12-30 Thread David M. Beazley

New submission from David M. Beazley beaz...@users.sourceforge.net:

The strict parameter to JSONDecoder() is undocumented and is confusing 
because someone might assume it has something to do with the encoding 
parameter or the general handling of parsing errors (which it doesn't).

As far as I can determine by reading the source, strict determines 
whether or not JSON strings are allowed to contain literal newlines in 
them or not.  For example (note: loads() passes its parameters to 
JSONDecoder):

 s = '{test:Hello\nWorld}'
 print(s)
{test:Hello
World}
 json.loads(s)
Traceback (most recent call last):
...
  File /tmp/lib/python3.0/json/decoder.py, line 159, in JSONString
return scanstring(match.string, match.end(), encoding, strict)
ValueError: Invalid control character at: line 1 column 14 (char 14)

 json.loads(s,strict=False)
{'test': 'Hello\nWorld'}
 

Note in this last example how the result has the literal newline 
embedded in it when strict is set False.

--
assignee: georg.brandl
components: Documentation
messages: 78550
nosy: beazley, georg.brandl
severity: normal
status: open
title: json.JSONDecoder() strict argument undocumented and potentially confusing
type: behavior
versions: Python 2.6, Python 3.0

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