summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMarc-André Lemburg <mal@egenix.com>2004-07-08 19:13:55 (GMT)
committerMarc-André Lemburg <mal@egenix.com>2004-07-08 19:13:55 (GMT)
commit1dffb120b733a45f9de3c1c4c2d10946ad6ea6d8 (patch)
treec86606d90f480189e2e572453e0596cd7f889def /Objects
parentd2d4598ec2e33e73efcbf295e630296b24a1b70b (diff)
downloadcpython-1dffb120b733a45f9de3c1c4c2d10946ad6ea6d8.zip
cpython-1dffb120b733a45f9de3c1c4c2d10946ad6ea6d8.tar.gz
cpython-1dffb120b733a45f9de3c1c4c2d10946ad6ea6d8.tar.bz2
.encode()/.decode() patch part 2.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/stringobject.c10
-rw-r--r--Objects/unicodeobject.c10
2 files changed, 20 insertions, 0 deletions
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 866e7e8..29562a9 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -2678,6 +2678,8 @@ string_encode(PyStringObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "|ss:encode", &encoding, &errors))
return NULL;
v = PyString_AsEncodedObject((PyObject *)self, encoding, errors);
+ if (v == NULL)
+ goto onError;
if (!PyString_Check(v) && !PyUnicode_Check(v)) {
PyErr_Format(PyExc_TypeError,
"encoder did not return a string/unicode object "
@@ -2687,6 +2689,9 @@ string_encode(PyStringObject *self, PyObject *args)
return NULL;
}
return v;
+
+ onError:
+ return NULL;
}
@@ -2710,6 +2715,8 @@ string_decode(PyStringObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "|ss:decode", &encoding, &errors))
return NULL;
v = PyString_AsDecodedObject((PyObject *)self, encoding, errors);
+ if (v == NULL)
+ goto onError;
if (!PyString_Check(v) && !PyUnicode_Check(v)) {
PyErr_Format(PyExc_TypeError,
"decoder did not return a string/unicode object "
@@ -2719,6 +2726,9 @@ string_decode(PyStringObject *self, PyObject *args)
return NULL;
}
return v;
+
+ onError:
+ return NULL;
}
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 4550023..2952c95 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -4935,6 +4935,8 @@ unicode_encode(PyUnicodeObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "|ss:encode", &encoding, &errors))
return NULL;
v = PyUnicode_AsEncodedObject((PyObject *)self, encoding, errors);
+ if (v == NULL)
+ goto onError;
if (!PyString_Check(v) && !PyUnicode_Check(v)) {
PyErr_Format(PyExc_TypeError,
"encoder did not return a string/unicode object "
@@ -4944,6 +4946,9 @@ unicode_encode(PyUnicodeObject *self, PyObject *args)
return NULL;
}
return v;
+
+ onError:
+ return NULL;
}
PyDoc_STRVAR(decode__doc__,
@@ -4966,6 +4971,8 @@ unicode_decode(PyStringObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "|ss:decode", &encoding, &errors))
return NULL;
v = PyUnicode_AsDecodedObject((PyObject *)self, encoding, errors);
+ if (v == NULL)
+ goto onError;
if (!PyString_Check(v) && !PyUnicode_Check(v)) {
PyErr_Format(PyExc_TypeError,
"decoder did not return a string/unicode object "
@@ -4975,6 +4982,9 @@ unicode_decode(PyStringObject *self, PyObject *args)
return NULL;
}
return v;
+
+ onError:
+ return NULL;
}
PyDoc_STRVAR(expandtabs__doc__,