summaryrefslogtreecommitdiffstats
path: root/Modules/_json.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-10-16 21:17:24 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-10-16 21:17:24 (GMT)
commita13d475901553b4a0ec7ed679ce2eac4598b557f (patch)
treedc0745a76b64e954cded961b6ec99bc08bdeac78 /Modules/_json.c
parent60192084c405292f874d886eed05ed83614d20c4 (diff)
downloadcpython-a13d475901553b4a0ec7ed679ce2eac4598b557f.zip
cpython-a13d475901553b4a0ec7ed679ce2eac4598b557f.tar.gz
cpython-a13d475901553b4a0ec7ed679ce2eac4598b557f.tar.bz2
merge r66932 and add a few py3k only checks
Diffstat (limited to 'Modules/_json.c')
-rw-r--r--Modules/_json.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Modules/_json.c b/Modules/_json.c
index 47c4a56..0068bda 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -179,11 +179,13 @@ raise_errmsg(char *msg, PyObject *s, Py_ssize_t end)
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);
- PyErr_SetObject(PyExc_ValueError, pymsg);
- Py_DECREF(pymsg);
+ if (pymsg) {
+ PyErr_SetObject(PyExc_ValueError, pymsg);
+ Py_DECREF(pymsg);
+ }
/*
def linecol(doc, pos):
@@ -602,7 +604,7 @@ py_encode_basestring_ascii(PyObject* self, PyObject *pystr)
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;