Skip to content
Snippets Groups Projects
Commit a1c439bbb9d8 authored by Bob Ippolito's avatar Bob Ippolito
Browse files

also test unicode and fix the JSONDecodeError issue

parent e1ff40afda1f
No related branches found
No related tags found
No related merge requests found
Version 2.1.7 released 2011-XX-XX Version 2.1.7 released 2011-XX-XX
* JSONDecodeError is now raised instead of ValueError when a document
ends with an opening quote and the C speedups are in use.
https://github.com/simplejson/simplejson/issues/15
* Updated documentation with information about JSONDecodeError * Updated documentation with information about JSONDecodeError
* Force unicode linebreak characters to be escaped (U+2028 and U+2029) * Force unicode linebreak characters to be escaped (U+2028 and U+2029)
http://timelessrepo.com/json-isnt-a-javascript-subset http://timelessrepo.com/json-isnt-a-javascript-subset
......
...@@ -483,7 +483,10 @@ ...@@ -483,7 +483,10 @@
PyObject *chunks = NULL; PyObject *chunks = NULL;
PyObject *chunk = NULL; PyObject *chunk = NULL;
if (end < 0 || len <= end) { if (len == end) {
raise_errmsg("Unterminated string starting at", pystr, begin);
}
else if (end < 0 || len < end) {
PyErr_SetString(PyExc_ValueError, "end is out of bounds"); PyErr_SetString(PyExc_ValueError, "end is out of bounds");
goto bail; goto bail;
} }
...@@ -689,7 +692,10 @@ ...@@ -689,7 +692,10 @@
PyObject *chunks = NULL; PyObject *chunks = NULL;
PyObject *chunk = NULL; PyObject *chunk = NULL;
if (end < 0 || len <= end) { if (len == end) {
raise_errmsg("Unterminated string starting at", pystr, begin);
}
else if (end < 0 || len < end) {
PyErr_SetString(PyExc_ValueError, "end is out of bounds"); PyErr_SetString(PyExc_ValueError, "end is out of bounds");
goto bail; goto bail;
} }
......
...@@ -22,4 +22,5 @@ ...@@ -22,4 +22,5 @@
def test_scan_error(self): def test_scan_error(self):
err = None err = None
for t in (str, unicode):
try: try:
...@@ -25,5 +26,5 @@ ...@@ -25,5 +26,5 @@
try: try:
json.loads('{"asdf": "') json.loads(t('{"asdf": "'))
except json.JSONDecodeError, e: except json.JSONDecodeError, e:
err = e err = e
else: else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment