]> granicus.if.org Git - python/commitdiff
Don't use deprecated function PyUnicode_GET_SIZE()
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 13 Nov 2013 13:17:30 +0000 (14:17 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 13 Nov 2013 13:17:30 +0000 (14:17 +0100)
Replace it with PyUnicode_GET_LENGTH() or PyUnicode_AsUnicodeAndSize()

Modules/_elementtree.c
Modules/posixmodule.c
Objects/namespaceobject.c

index cb7069d69f0fa853911a54a45dc15a9f2d4bc3b7..797e357dfd612321f3e7f121725aacc93bc4d129 100644 (file)
@@ -3461,7 +3461,7 @@ xmlparser_parse_whole(XMLParserObject* self, PyObject* args)
 
         if (PyUnicode_CheckExact(buffer)) {
             /* A unicode object is encoded into bytes using UTF-8 */
-            if (PyUnicode_GET_SIZE(buffer) == 0) {
+            if (PyUnicode_GET_LENGTH(buffer) == 0) {
                 Py_DECREF(buffer);
                 break;
             }
index f282f998332a3442d372875b8387d753807746c5..5e5f35520caceda1e44d558513a2088abf4701f8 100644 (file)
@@ -829,15 +829,14 @@ path_converter(PyObject *o, void *p) {
     if (unicode) {
 #ifdef MS_WINDOWS
         wchar_t *wide;
-        length = PyUnicode_GET_SIZE(unicode);
-        if (length > 32767) {
-            FORMAT_EXCEPTION(PyExc_ValueError, "%s too long for Windows");
+
+        wide = PyUnicode_AsUnicodeAndSize(unicode, &length);
+        if (!wide) {
             Py_DECREF(unicode);
             return 0;
         }
-
-        wide = PyUnicode_AsUnicode(unicode);
-        if (!wide) {
+        if (length > 32767) {
+            FORMAT_EXCEPTION(PyExc_ValueError, "%s too long for Windows");
             Py_DECREF(unicode);
             return 0;
         }
index 9e950946aad786f77802876f9ccb9f7313fc9259..720ac0d30fc09ca397ccbd76d6cfb669ac2adfae 100644 (file)
@@ -101,7 +101,7 @@ namespace_repr(PyObject *ns)
         goto error;
 
     while ((key = PyIter_Next(keys_iter)) != NULL) {
-        if (PyUnicode_Check(key) && PyUnicode_GET_SIZE(key) > 0) {
+        if (PyUnicode_Check(key) && PyUnicode_GET_LENGTH(key) > 0) {
             PyObject *value, *item;
 
             value = PyDict_GetItem(d, key);