]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport MAL's checkin 2.105:
authorThomas Wouters <thomas@python.org>
Wed, 23 May 2001 13:14:24 +0000 (13:14 +0000)
committerThomas Wouters <thomas@python.org>
Wed, 23 May 2001 13:14:24 +0000 (13:14 +0000)
Fix for bug #417030: "print '%*s' fails for unicode string"

Objects/stringobject.c

index 7fccd1be96a81b86803216ebcd6e7563748e8f74..4de8b1f26d054ea0c8aba4b9feedeb6ab70e797e 100644 (file)
@@ -2779,6 +2779,7 @@ PyString_Format(PyObject *format, PyObject *args)
                        int len;
                        char formatbuf[FORMATBUFLEN]; /* For format{float,int,char}() */
                        char *fmt_start = fmt;
+                       int argidx_start = argidx;
                        
                        fmt++;
                        if (*fmt == '(') {
@@ -2932,6 +2933,7 @@ PyString_Format(PyObject *format, PyObject *args)
                        case 'r':
                                if (PyUnicode_Check(v)) {
                                        fmt = fmt_start;
+                                       argidx = argidx_start;
                                        goto unicode;
                                }
                                if (c == 's')
@@ -3096,8 +3098,7 @@ PyString_Format(PyObject *format, PyObject *args)
                Py_DECREF(args);
                args_owned = 0;
        }
-       /* Fiddle args right (remove the first argidx-1 arguments) */
-       --argidx;
+       /* Fiddle args right (remove the first argidx arguments) */
        if (PyTuple_Check(orig_args) && argidx > 0) {
                PyObject *v;
                int n = PyTuple_GET_SIZE(orig_args) - argidx;