summaryrefslogtreecommitdiffstats
path: root/Modules/_json.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_json.c')
-rw-r--r--Modules/_json.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/Modules/_json.c b/Modules/_json.c
index 9430990..0bf475e 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -312,23 +312,22 @@ escape_unicode(PyObject *pystr)
static void
raise_errmsg(char *msg, PyObject *s, Py_ssize_t end)
{
- /* Use the Python function json.decoder.errmsg to raise a nice
- looking ValueError exception */
- static PyObject *errmsg_fn = NULL;
- PyObject *pymsg;
- if (errmsg_fn == NULL) {
+ /* Use JSONDecodeError exception to raise a nice looking ValueError subclass */
+ static PyObject *JSONDecodeError = NULL;
+ PyObject *exc;
+ if (JSONDecodeError == NULL) {
PyObject *decoder = PyImport_ImportModule("json.decoder");
if (decoder == NULL)
return;
- errmsg_fn = PyObject_GetAttrString(decoder, "errmsg");
+ JSONDecodeError = PyObject_GetAttrString(decoder, "JSONDecodeError");
Py_DECREF(decoder);
- if (errmsg_fn == NULL)
+ if (JSONDecodeError == NULL)
return;
}
- pymsg = PyObject_CallFunction(errmsg_fn, "(zOn)", msg, s, end);
- if (pymsg) {
- PyErr_SetObject(PyExc_ValueError, pymsg);
- Py_DECREF(pymsg);
+ exc = PyObject_CallFunction(JSONDecodeError, "(zOn)", msg, s, end);
+ if (exc) {
+ PyErr_SetObject(JSONDecodeError, exc);
+ Py_DECREF(exc);
}
}