[PATCH] base85: use z modifier to print Py_ssize_t
Adrian Buehlmann
adrian at cadifra.com
Mon Jun 4 07:29:12 UTC 2012
On 2012-06-04 09:15, David Soria Parra wrote:
> # HG changeset patch
> # User David Soria Parra <dsp at php.net>
> # Date 1338794040 -7200
> # Node ID 5d6ccf796a9410cbef419478e5bca67722f214ea
> # Parent 0a0cf3f26938ff7a084f2dcc9e59152ac6060e1e
> base85: use z modifier to print Py_ssize_t
>
> Python converts to z modifiert to PY_SIZE_FORMAT_T internally. Using the
> z modifier is the right way to print Py_ssize_t arguments. This squelches a
> conversion warning.
Thanks.
Using the zd format specifier was my first idea as well, but that format
doesn't exist in Python 2.4 (it was introduced with Python 2.5):
http://docs.python.org/release/2.4/api/stringObjects.html
http://docs.python.org/release/2.5/api/stringObjects.html
So we need to take care of Python 2.4, which we still have to support.
I'm working on this problem. See
http://bz.selenic.com/show_bug.cgi?id=3481
> diff --git a/mercurial/base85.c b/mercurial/base85.c
> --- a/mercurial/base85.c
> +++ b/mercurial/base85.c
> @@ -111,7 +111,7 @@
> if (c < 0)
> return PyErr_Format(
> PyExc_ValueError,
> - "bad base85 character at position %d", i);
> + "bad base85 character at position %zd", i);
> acc = acc * 85 + c;
> }
> if (i++ < len)
> @@ -120,13 +120,13 @@
> if (c < 0)
> return PyErr_Format(
> PyExc_ValueError,
> - "bad base85 character at position %d", i);
> + "bad base85 character at position %zd", i);
> /* overflow detection: 0xffffffff == "|NsC0",
> * "|NsC" == 0x03030303 */
> if (acc > 0x03030303 || (acc *= 85) > 0xffffffff - c)
> return PyErr_Format(
> PyExc_ValueError,
> - "bad base85 sequence at position %d", i);
> + "bad base85 sequence at position %zd", i);
> acc += c;
> }
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
>
More information about the Mercurial-devel
mailing list