summaryrefslogtreecommitdiffstats
path: root/Python/codecs.c
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2013-11-15 11:47:37 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2013-11-15 11:47:37 (GMT)
commitc4c2580d43880ac2013aff5e72674bae379c99a4 (patch)
treea9a4ab0cc66adf2b1542a33153541e03c230987c /Python/codecs.c
parent91d2c5674a059dcf8820fb7585c03b5491449605 (diff)
downloadcpython-c4c2580d43880ac2013aff5e72674bae379c99a4.zip
cpython-c4c2580d43880ac2013aff5e72674bae379c99a4.tar.gz
cpython-c4c2580d43880ac2013aff5e72674bae379c99a4.tar.bz2
Close 19609: narrow scope of codec exc chaining
Diffstat (limited to 'Python/codecs.c')
-rw-r--r--Python/codecs.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Python/codecs.c b/Python/codecs.c
index e2edc26..fe0cab4 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -370,8 +370,10 @@ PyObject *PyCodec_Encode(PyObject *object,
goto onError;
result = PyEval_CallObject(encoder, args);
- if (result == NULL)
+ if (result == NULL) {
+ wrap_codec_error("encoding", encoding);
goto onError;
+ }
if (!PyTuple_Check(result) ||
PyTuple_GET_SIZE(result) != 2) {
@@ -392,7 +394,6 @@ PyObject *PyCodec_Encode(PyObject *object,
Py_XDECREF(result);
Py_XDECREF(args);
Py_XDECREF(encoder);
- wrap_codec_error("encoding", encoding);
return NULL;
}
@@ -418,8 +419,10 @@ PyObject *PyCodec_Decode(PyObject *object,
goto onError;
result = PyEval_CallObject(decoder,args);
- if (result == NULL)
+ if (result == NULL) {
+ wrap_codec_error("decoding", encoding);
goto onError;
+ }
if (!PyTuple_Check(result) ||
PyTuple_GET_SIZE(result) != 2) {
PyErr_SetString(PyExc_TypeError,
@@ -439,7 +442,6 @@ PyObject *PyCodec_Decode(PyObject *object,
Py_XDECREF(args);
Py_XDECREF(decoder);
Py_XDECREF(result);
- wrap_codec_error("decoding", encoding);
return NULL;
}