diff Python/getargs.c @ 72861:6358e5d29dea

Use PyUnicode_AsUnicodeAndSize() instead of PyUnicode_GET_SIZE()
author Victor Stinner <victor.stinner@haypocalc.com>
date Tue, 11 Oct 2011 21:55:01 +0200
parents b66033a0f140
children 9685f893fffe
line wrap: on
line diff
--- a/Python/getargs.c	Tue Oct 11 20:58:41 2011 +0200
+++ b/Python/getargs.c	Tue Oct 11 21:55:01 2011 +0200
@@ -982,10 +982,11 @@
                 STORE_SIZE(0);
             }
             else if (PyUnicode_Check(arg)) {
-                *p = PyUnicode_AS_UNICODE(arg);
+                Py_ssize_t len;
+                *p = PyUnicode_AsUnicodeAndSize(arg, &len);
                 if (*p == NULL)
                     RETURN_ERR_OCCURRED;
-                STORE_SIZE(PyUnicode_GET_SIZE(arg));
+                STORE_SIZE(len);
             }
             else
                 return converterr("str or None", arg, msgbuf, bufsize);
@@ -995,10 +996,11 @@
             if (c == 'Z' && arg == Py_None)
                 *p = NULL;
             else if (PyUnicode_Check(arg)) {
-                *p = PyUnicode_AS_UNICODE(arg);
+                Py_ssize_t len;
+                *p = PyUnicode_AsUnicodeAndSize(arg, &len);
                 if (*p == NULL)
                     RETURN_ERR_OCCURRED;
-                if (Py_UNICODE_strlen(*p) != PyUnicode_GET_SIZE(arg))
+                if (Py_UNICODE_strlen(*p) != len)
                     return converterr(
                         "str without null character or None",
                         arg, msgbuf, bufsize);