[Python-Dev] Py_ssize_t formatting (original) (raw)

Neal Norwitz nnorwitz at gmail.com
Sat May 13 20:16:21 CEST 2006


On 5/13/06, "Martin v. Löwis" <martin at v.loewis.de> wrote:

> '%zd' won't work since my value can be negative, and the 'z' modifier > converts the argument to sizet. That's a bug. It should print it signed. If unsigned printing of sizet is desired, %zu should be used.

Looking in stringobject.c, I don't see how %zu (or %lu) can be used with String_FromFormatV. Here's the code around line 260 (note ssize_t in the comment really means Py_ssize_t):

                    /* handle the long flag, but only for %ld.  others
                       can be added when necessary. */
                    if (*f == 'l' && *(f+1) == 'd') {
                            longflag = 1;
                            ++f;
                    }
                    /* handle the ssize_t flag. */
                    if (*f == 'z' && *(f+1) == 'd') {
                            size_tflag = 1;
                            ++f;
                    }

n



More information about the Python-Dev mailing list