This is from Py2.6rc1 Misc/NEWS
- Issue #3743: In a few places, PY_FORMAT_SIZE_T was incorrectly used with
PyString_FromFormat or PyErr_Format to display size_t values. The macro
PY_FORMAT_SIZE_T is designed to select the correct format for the OS
``printf`` function, whereas PyString_FromFormat has an independent
implementation and uses "%zd" on all platforms for size_t values.
This makes a difference on win64, where ``printf`` needs "%Id" to display
64bit values.
So our usage of PyErr_Format + PY_FORMAT_SIZE_T are broken, and
clearly wrong on Windows 64..
Likely I am the guy to blame, as I advocated the usage
PY_FORMAT_SIZE_T... At that time, I did not realized that
PyString_FromFormatV did not handled PY_FORMAT_SIZE_T on input, but
actually just translated 'z' modifier to PY_FORMAT_SIZE_T... I'm very
sorry for this...
So, you should change any PyErr_Format() call to use 'z' modifiers, however:
A) Python <= 2.4: PyString_FromFormatV() does not handle 'z' modifier,
as the Py_ssize_t do not exit in that version. Then condional
compilation requiered for every call to PyErr_Format()...
B) Python >= 2.5: we can use 'z' modifier safely with
PyString_FromFormatV(). However, from Python's include/pyerrors.h, you
can see
PyAPI_FUNC(PyObject *) PyErr_Format(PyObject *, const char *, ...)
Py_GCC_ATTRIBUTE((format(printf, 2, 3)));
then a Windows port of GCC (correctly) generates warnings because the
'z' modifier is invalid in that platform... Of course, this is
CPython's fault: PyErr_Format() should not be decorated with the
'format(printf,...)' attribute, at least not on Windows...
So.... Do any of you have any suggestion on how to properly handle
this nightmare???
PS: Once again, I had to spend my precious development time related to
Windows issues... We do really need help here: I do not have any
expertise on Windows, nor it is my favourite platform, I just test on
Windows cor completennes and because I have it for "free" ;-) because
it comes pre-installed with my notebook.
--
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev