Fix misuse of PyUnicode_GET_SIZE() => PyUnicode_GET_LENGTH()
authorVictor Stinner <victor.stinner@haypocalc.com>
Mon, 21 Nov 2011 01:49:52 +0000 (02:49 +0100)
committerVictor Stinner <victor.stinner@haypocalc.com>
Mon, 21 Nov 2011 01:49:52 +0000 (02:49 +0100)
And PyUnicode_GetSize() => PyUnicode_GetLength()

Modules/_csv.c
Modules/_datetimemodule.c
Modules/_gestalt.c
Modules/_io/stringio.c
Modules/_io/textio.c
Objects/bytesobject.c
Objects/exceptions.c
Objects/unicodeobject.c
PC/import_nt.c
Python/_warnings.c

index c02ee384b2cb4d20d5054b47abd9c62033bd5af8..443309c59bbaf9afb4b9face5fb6f021020a4c25 100644 (file)
@@ -207,7 +207,7 @@ _set_char(const char *name, Py_UCS4 *target, PyObject *src, Py_UCS4 dflt)
         *target = '\0';
         if (src != Py_None) {
             Py_ssize_t len;
-            len = PyUnicode_GetSize(src);
+            len = PyUnicode_GetLength(src);
             if (len > 1) {
                 PyErr_Format(PyExc_TypeError,
                     "\"%s\" must be an 1-character string",
index 316e1d72fdc11284cf88bd67baeb205a5cb4ade7..b38423376a387b3717023b8512788dcedf66b4e4 100644 (file)
@@ -1080,7 +1080,7 @@ make_Zreplacement(PyObject *object, PyObject *tzinfoarg)
     PyObject *tzinfo = get_tzinfo_member(object);
     PyObject *Zreplacement = PyUnicode_FromStringAndSize(NULL, 0);
     _Py_IDENTIFIER(replace);
-       
+
     if (Zreplacement == NULL)
         return NULL;
     if (tzinfo == Py_None || tzinfo == NULL)
@@ -2673,7 +2673,7 @@ date_format(PyDateTime_Date *self, PyObject *args)
         return NULL;
 
     /* if the format is zero length, return str(self) */
-    if (PyUnicode_GetSize(format) == 0)
+    if (PyUnicode_GetLength(format) == 0)
         return PyObject_Str((PyObject *)self);
 
     return _PyObject_CallMethodId((PyObject *)self, &PyId_strftime, "O", format);
index a45780fe795159d72e74836a1bedba9daa887063..cd3068334a7fbce76c6faea290032df7426ffcf7 100644 (file)
@@ -33,7 +33,7 @@ static int
 convert_to_OSType(PyObject *v, OSType *pr)
 {
     uint32_t tmp;
-    if (!PyUnicode_Check(v) || PyUnicode_GetSize(v) != 4) {
+    if (!PyUnicode_Check(v) || PyUnicode_GetLength(v) != 4) {
     PyErr_SetString(PyExc_TypeError,
                     "OSType arg must be string of 4 chars");
     return 0;
index 774999015c9e172e0b4cd8debe5b0f3122ca6819..c4794c9474e01f2da0766f2e8b96ce66c5e70baf 100644 (file)
@@ -730,7 +730,7 @@ stringio_init(stringio *self, PyObject *args, PyObject *kwds)
        and copy it */
     self->string_size = 0;
     if (value && value != Py_None)
-        value_len = PyUnicode_GetSize(value);
+        value_len = PyUnicode_GetLength(value);
     else
         value_len = 0;
     if (value_len > 0) {
index 91a389195e48926acfc4f3f0afe7660f3a168ebd..07dad3a8ba1eb1beb66ca28fa139fd44fe3665a4 100644 (file)
@@ -2144,7 +2144,7 @@ textiowrapper_seek(textio *self, PyObject *args)
         textiowrapper_set_decoded_chars(self, decoded);
 
         /* Skip chars_to_skip of the decoded characters. */
-        if (PyUnicode_GetSize(self->decoded_chars) < cookie.chars_to_skip) {
+        if (PyUnicode_GetLength(self->decoded_chars) < cookie.chars_to_skip) {
             PyErr_SetString(PyExc_IOError, "can't restore logical file position");
             goto fail;
         }
@@ -2208,7 +2208,7 @@ textiowrapper_tell(textio *self, PyObject *args)
         goto fail;
 
     if (self->decoder == NULL || self->snapshot == NULL) {
-        assert (self->decoded_chars == NULL || PyUnicode_GetSize(self->decoded_chars) == 0);
+        assert (self->decoded_chars == NULL || PyUnicode_GetLength(self->decoded_chars) == 0);
         return posobj;
     }
 
index 7438a70332aa57bead73e8e73cb324baa609a239..a89798a167b409cfe6b114bfaa390bc695cacf3b 100644 (file)
@@ -2941,7 +2941,7 @@ _PyBytes_FormatLong(PyObject *val, int flags, int prec, int type,
         PyErr_BadInternalCall();
         return NULL;
     }
-    llen = PyUnicode_GetSize(result);
+    llen = PyUnicode_GetLength(result);
     if (llen > INT_MAX) {
         PyErr_SetString(PyExc_ValueError,
                         "string too large in _PyBytes_FormatLong");
index a1b79a86bc4c1026df765833e28503bec60415aa..37b78757736abb020ac0e3e196a13c508c84e5cc 100644 (file)
@@ -1273,7 +1273,7 @@ PyUnicodeEncodeError_GetStart(PyObject *exc, Py_ssize_t *start)
     if (!obj)
         return -1;
     *start = ((PyUnicodeErrorObject *)exc)->start;
-    size = PyUnicode_GET_SIZE(obj);
+    size = PyUnicode_GET_LENGTH(obj);
     if (*start<0)
         *start = 0; /*XXX check for values <0*/
     if (*start>=size)
@@ -1341,7 +1341,7 @@ PyUnicodeEncodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
     if (!obj)
         return -1;
     *end = ((PyUnicodeErrorObject *)exc)->end;
-    size = PyUnicode_GET_SIZE(obj);
+    size = PyUnicode_GET_LENGTH(obj);
     if (*end<1)
         *end = 1;
     if (*end>size)
index 1e44357c2fb0f71d38f39f77c2220e56b0211d93..6798ef814523d16e23079396a641033b9eb17676 100644 (file)
@@ -4784,7 +4784,7 @@ _PyUnicode_AsUTF8String(PyObject *unicode, const char *errors)
             if (PyBytes_Check(rep))
                 repsize = PyBytes_GET_SIZE(rep);
             else
-                repsize = PyUnicode_GET_SIZE(rep);
+                repsize = PyUnicode_GET_LENGTH(rep);
 
             if (repsize > 4) {
                 Py_ssize_t offset;
@@ -8187,7 +8187,7 @@ charmap_encoding_error(
             Py_DECREF(repunicode);
             return -1;
         }
-        repsize = PyUnicode_GET_SIZE(repunicode);
+        repsize = PyUnicode_GET_LENGTH(repunicode);
         data = PyUnicode_DATA(repunicode);
         kind = PyUnicode_KIND(repunicode);
         for (index = 0; index < repsize; index++) {
index dfbf05481033298c62fe3e72efda258f773791fc..b9b36dca5e2d437111e0a32da44fda79ef6b676f 100644 (file)
@@ -86,12 +86,11 @@ _PyWin_FindRegisteredModule(PyObject *moduleName,
         suffix = PyUnicode_FromString(fdp->suffix);
         if (suffix == NULL)
             return NULL;
-        wsuffix = PyUnicode_AsUnicode(suffix);
+        wsuffix = PyUnicode_AsUnicodeAndSize(suffix, &extLen);
         if (wsuffix == NULL) {
             Py_DECREF(suffix);
             return NULL;
         }
-        extLen = PyUnicode_GET_SIZE(suffix);
         if ((Py_ssize_t)modNameSize > extLen &&
             _wcsnicmp(pathBuf + ((Py_ssize_t)modNameSize-extLen-1),
                       wsuffix,
index 2e5b0dd4e28149e53696a7984eb63727aab80ac0..a494dd9a3c721a75fb58effc362d70d04e850ef0 100644 (file)
@@ -203,13 +203,13 @@ normalize_module(PyObject *filename)
 
     mod_str = _PyUnicode_AsString(filename);
     if (mod_str == NULL)
-            return NULL;
-    len = PyUnicode_GetSize(filename);
+        return NULL;
+    len = PyUnicode_GetLength(filename);
     if (len < 0)
         return NULL;
     if (len >= 3 &&
         strncmp(mod_str + (len - 3), ".py", 3) == 0) {
-        module = PyUnicode_FromStringAndSize(mod_str, len-3);
+        module = PyUnicode_Substring(filename, 0, len-3);
     }
     else {
         module = filename;
@@ -506,7 +506,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
         if (PyUnicode_READY(*filename))
             goto handle_error;
 
-        len = PyUnicode_GetSize(*filename);
+        len = PyUnicode_GetLength(*filename);
         kind = PyUnicode_KIND(*filename);
         data = PyUnicode_DATA(*filename);
 
@@ -690,7 +690,7 @@ warnings_warn_explicit(PyObject *self, PyObject *args, PyObject *kwds)
         }
 
         /* Split the source into lines. */
-        source_list = PyObject_CallMethodObjArgs(source, 
+        source_list = PyObject_CallMethodObjArgs(source,
                                                  PyId_splitlines.object,
                                                  NULL);
         Py_DECREF(source);