Eric V. Smith <[email protected]> added the comment:
I finally got around to reviewing the patch. A couple of comments:
1. There should be some tests for str.__format__, not just str.format. This is
really a bug with str.__format__, after all. I can add those.
2. The bigger issue is that the other built in formatters have this same
problem.
>>> format(3, '\x00<6')
'3 '
>>> format(3., '\x00<6')
'3.0 '
>>> format('3', '\x00<6')
'3\x00\x00\x00\x00\x00'
>>> format(3+1j, '\x00<6')
'(3+1j)'
[38654 refs]
>>> format(3+1j, '\x00<10')
'(3+1j) '
I think the fix is basically the same as str.__format__ (but in
format_int_or_long_internal, format_float_internal, and
format_complex_internal). I tried that and it worked, but I haven't had time to
write tests for them. If you (Davide) can do that, great. Otherwise I'll try
and grab some time this week.
Changing the subject to match the wider scope of the problem.
----------
stage: commit review -> patch review
title: str.format cannot fill with \x00 char -> builtin __format__ methods
cannot fill with \x00 char
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue12546>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com