[Python-checkins] r47170 - python/trunk/Modules/_ctypes/callproc.c

Tim Peters tim.peters at gmail.com
Fri Jun 30 10:20:18 CEST 2006


> Author: neal.norwitz
> Date: Fri Jun 30 09:32:16 2006
> New Revision: 47170
>
> Modified:
>    python/trunk/Modules/_ctypes/callproc.c
> Log:
> Silence compiler warning
>
> Modified: python/trunk/Modules/_ctypes/callproc.c
> ==============================================================================
> --- python/trunk/Modules/_ctypes/callproc.c     (original)
> +++ python/trunk/Modules/_ctypes/callproc.c     Fri Jun 30 09:32:16 2006
> @@ -82,6 +82,10 @@
>  #define DONT_USE_SEH
>  #endif
>
> +#ifndef PY_FORMAT_SIZE_T
> +#define PY_FORMAT_SIZE_T ""
> +#endif
> +
>  #ifdef MS_WIN32
>  PyObject *ComError;
>
> @@ -1486,7 +1490,8 @@
>         }
>         if (size < dict->size) {
>                 PyErr_Format(PyExc_ValueError,
> -                            "minimum size is %d", dict->size);
> +                            "minimum size is %" PY_FORMAT_SIZE_T "d",
> +                            dict->size);

Unfortunately, that doesn't make sense -- there's no guarantee that
PyErr_Format() can understand PY_FORMAT_SIZE_T's expansion.
PY_FORMAT_SIZE_T should only be used in calls to C's format functions
(like printf or sprintf).  PyErr_Format() in 2.5 makes sense of "%zd"
itself, but before 2.5 does not, so "%zd" can't be used here either.

#if PY_VERSION_HEX < 0x02050000
                            "minimum size is %d", dict->size);
#else
                            "minimum size is %zd", dict->size);
#endif

makes sense.  That directly reflects that this module uses C int
before 2.5, but uses Py_ssize_t starting with 2.5.


More information about the Python-checkins mailing list