Message278467
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. |
|
Date |
User |
Action |
Args |
2016-10-11 08:56:20 | xiang.zhang | set | recipients:
+ xiang.zhang, vstinner, serhiy.storchaka |
2016-10-11 08:56:20 | xiang.zhang | set | messageid: <1476176180.11.0.398413685253.issue28415@psf.upfronthosting.co.za> |
2016-10-11 08:56:20 | xiang.zhang | link | issue28415 messages |
2016-10-11 08:56:19 | xiang.zhang | create | |
|