Index: Lib/json/decoder.py =================================================================== --- Lib/json/decoder.py (révision 65915) +++ Lib/json/decoder.py (copie de travail) @@ -18,11 +18,15 @@ def linecol(doc, pos): - lineno = doc.count('\n', 0, pos) + 1 + if isinstance(doc, bytes): + newline = b'\n' + else: + newline = '\n' + lineno = doc.count(newline, 0, pos) + 1 if lineno == 1: colno = pos else: - colno = pos - doc.rindex('\n', 0, pos) + colno = pos - doc.rindex(newline, 0, pos) return lineno, colno Index: Modules/_json.c =================================================================== --- Modules/_json.c (révision 65915) +++ Modules/_json.c (copie de travail) @@ -179,11 +179,13 @@ errmsg_fn = PyObject_GetAttrString(decoder, "errmsg"); if (errmsg_fn == NULL) return; - Py_XDECREF(decoder); + Py_DECREF(decoder); } pymsg = PyObject_CallFunction(errmsg_fn, "(zOn)", msg, s, end); + if (pymsg) { PyErr_SetObject(PyExc_ValueError, pymsg); Py_DECREF(pymsg); + } /* def linecol(doc, pos): @@ -602,7 +604,7 @@ Py_TYPE(pystr)->tp_name); return NULL; } - if (PyBytes_Check(rval)) { + if (rval != NULL && PyBytes_Check(rval)) { PyObject *urval = PyUnicode_DecodeASCII(PyBytes_AS_STRING(rval), PyBytes_GET_SIZE(rval), NULL); Py_DECREF(rval); return urval;