Gareth Rees added the comment: Test case minimization:
Python 3.6.1 (default, Apr 24 2017, 06:18:27) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> b'a\x00%(a)s' % {b'a': b'a'} b'a\x00%(a)s' It seems that all formatting operations after a zero byte are ignored. This is because the code for parsing the format string (in _PyBytes_FormatEx in Objects/bytesobject.c) uses the following approach to find the next % character: while (--fmtcnt >= 0) { if (*fmt != '%') { Py_ssize_t len; char *pos; pos = strchr(fmt + 1, '%'); But strchr uses the C notion of strings, which are terminated by a zero byte. ---------- nosy: +g...@garethrees.org _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30943> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com