diff Python/codecs.c @ 87109:4ea622c085ca

Close 19609: narrow scope of codec exc chaining
author Nick Coghlan <ncoghlan@gmail.com>
date Fri, 15 Nov 2013 21:47:37 +1000
parents 854a2cea31b9
children 0d9624f2ff43
line wrap: on
line diff
--- a/Python/codecs.c	Thu Nov 14 16:16:29 2013 -0800
+++ b/Python/codecs.c	Fri Nov 15 21:47:37 2013 +1000
@@ -370,8 +370,10 @@
         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 @@
     Py_XDECREF(result);
     Py_XDECREF(args);
     Py_XDECREF(encoder);
-    wrap_codec_error("encoding", encoding);
     return NULL;
 }
 
@@ -418,8 +419,10 @@
         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 @@
     Py_XDECREF(args);
     Py_XDECREF(decoder);
     Py_XDECREF(result);
-    wrap_codec_error("decoding", encoding);
     return NULL;
 }