āžœ

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xiang.zhang
Recipients serhiy.storchaka, vstinner, xiang.zhang
Date 2016-10-11.08:56:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1476176180.11.0.398413685253.issue28415@psf.upfronthosting.co.za>
In-reply-to
Content
Although declared *exactly equivalent* to printf in the doc, PyUnicode_FromFormat could generate different result from printf with the same format.

For example:

from ctypes import pythonapi, py_object, c_int
f = getattr(pythonapi, 'PyUnicode_FromFormat')
f.restype = py_object
f(b'%010.5d', c_int(100))
'0000000100'

while printf outputs:

printf("%010.5d\n", 100);
     00100

I use both gcc and clang to compile and get the same result. gcc gives me a warning:

warning: '0' flag ignored with precision and ā€˜%dā€™ gnu_printf format

I am not sure this should be fixed. It seems the change could break backwards compatibility.
History
Date User Action Args
2016-10-11 08:56:20xiang.zhangsetrecipients: + xiang.zhang, vstinner, serhiy.storchaka
2016-10-11 08:56:20xiang.zhangsetmessageid: <1476176180.11.0.398413685253.issue28415@psf.upfronthosting.co.za>
2016-10-11 08:56:20xiang.zhanglinkissue28415 messages
2016-10-11 08:56:19xiang.zhangcreate