[Python-checkins] cpython: MultibyteCodec_Encode() checks if PyUnicode_AS_UNICODE() failed

victor.stinner python-checkins at python.org
Mon Nov 21 02:50:23 CET 2011


http://hg.python.org/cpython/rev/2d106508ff37
changeset:   73656:2d106508ff37
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Mon Nov 21 02:50:14 2011 +0100
summary:
  MultibyteCodec_Encode() checks if PyUnicode_AS_UNICODE() failed

files:
  Modules/cjkcodecs/multibytecodec.c |  7 +++++--
  1 files changed, 5 insertions(+), 2 deletions(-)


diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -574,8 +574,11 @@
         }
     }
 
-    data = PyUnicode_AS_UNICODE(arg);
-    datalen = PyUnicode_GET_SIZE(arg);
+    data = PyUnicode_AsUnicodeAndSize(arg, &datalen);
+    if (data == NULL) {
+        Py_XDECREF(ucvt);
+        return NULL;
+    }
 
     errorcb = internal_error_callback(errors);
     if (errorcb == NULL) {

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list