New submission from Xiang Zhang: 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. ---------- components: Interpreter Core messages: 278467 nosy: haypo, serhiy.storchaka, xiang.zhang priority: normal severity: normal status: open title: PyUnicode_FromFromat interger format handling different from printf about zeropad type: behavior versions: Python 3.5, Python 3.6, Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue28415> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com