classification
Title: PY_FORMAT_SIZE_T is not for PyString_FromFormat
Type: Stage:
Components: Versions: Python 3.0, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: amaury.forgeotdarc Nosy List: amaury.forgeotdarc, benjamin.peterson, christian.heimes, georg.brandl, loewis, rpetrov
Priority: release blocker Keywords: patch

Created on 2008-08-31 20:40 by amaury.forgeotdarc, last changed 2008-09-10 22:29 by benjamin.peterson. This issue is now closed.

Files
File name Uploaded Description Edit
fromformat.patch amaury.forgeotdarc, 2008-08-31 20:40 for python 2.6
Messages (12)
msg72212 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-08-31 20:40
test_deque fails on win64 buildbot:
  AssertionError: 'deque([7, 8, 9], maxlen=%Id)' != 'deque([7, 8, 9],
maxlen=3)'

A PY_FORMAT_SIZE_T format is incorrectly used with PyUnicode_FromFormat.
The correct format here is "%zd". PY_FORMAT_SIZE_T should be reserved
for the OS printf routines, PyOS_snprintf, PySys_WriteStderr.

The attached patch replaces 
   "%" PY_FORMAT_SIZE_T "%d" 
with
   "%zd"
msg72213 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-08-31 20:59
Looks good to me.
msg72214 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-08-31 21:17
O
msg72215 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-08-31 21:45
You're right, Chris, I didn't think of that...
msg72293 - (view) Author: Roumen Petrov (rpetrov) * Date: 2008-09-01 20:58
Since not all platforms support "%zd" the patch has to be rewritten.
May be PY_FORMAT_SIZE_T isn't correctly defined in Include/pyport.h for
the used "C" library.
msg72295 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-09-01 21:30
No, and this is the reason of the patch:
PyUnicode_FromFormat and PyErr_Format do not use the platform printf.

The code (in Objects/unicodeobject.c) is platform-independent; %zd is
the way to print a ssize_t variable on all platforms.

My only observation is that %zd does not exist before python2.5, and the
code of "multiprocessing" currently seems to be compatible with python
2.4. I don't know if this is important.
msg72296 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-09-01 21:31
> You're right, Chris, I didn't think of that...
Did I miss something? or some joke I do not understand?
msg72902 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-09-09 19:43
It was a (lame attempt at a) joke... sorry :D
msg72949 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-09-10 08:20
Jumping to "release blocker", since it causes a buildbot to fail.
Review needed.
msg72969 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-09-10 15:50
The patch is fine, please apply.
msg72991 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-09-10 22:25
Committed r66377 and r66378.
msg72992 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-09-10 22:29
You forgot to update Parser/asdl_c.py; I did it in r66379.
History
Date User Action Args
2008-09-10 22:29:02benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg72992
2008-09-10 22:25:13amaury.forgeotdarcsetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg72991
2008-09-10 15:50:17loewissetkeywords: - needs review
assignee: amaury.forgeotdarc
resolution: accepted
messages: + msg72969
nosy: + loewis
2008-09-10 08:20:07amaury.forgeotdarcsetpriority: release blocker
messages: + msg72949
2008-09-09 19:43:12georg.brandlsetmessages: + msg72902
2008-09-01 21:31:06amaury.forgeotdarcsetmessages: + msg72296
2008-09-01 21:30:11amaury.forgeotdarcsetkeywords: + needs review
messages: + msg72295
2008-09-01 20:58:09rpetrovsetnosy: + rpetrov
messages: + msg72293
2008-08-31 21:45:03georg.brandlsetmessages: + msg72215
2008-08-31 21:17:58christian.heimessetnosy: + christian.heimes
messages: + msg72214
2008-08-31 20:59:03georg.brandlsetnosy: + georg.brandl
messages: + msg72213
2008-08-31 20:40:38amaury.forgeotdarccreate