Message28190
Logged In: YES
user_id=11375
So, what should '%s' % {} do? Should it be 1) '{}' or 2) an
error because the argument is a mapping but the format
specifier doesn't have a '(key)'?
I've attached a draft patch that fixes stringobject.c; if
the approach is deemed OK, I'll apply it to unicodeobject.c,
too. PyString_Format() records the type of argument being
processed (a tuple or a mapping) and raises ValueError if
you mix them, at the cost of two extra comparisons for each
format specifier processed. This preserves the current
behaviour of '%s' % dictionary.
Questions: 1) is the approach reasonably clear? 2) are the
additional two comparisons unacceptably slow? 3) Is
ValueError the right exception? 4) can someone come up with
a better exception message than "both keyed and unkeyed
format specifiers used"?
|
|
Date |
User |
Action |
Args |
2007-08-23 14:39:20 | admin | link | issue1467929 messages |
2007-08-23 14:39:20 | admin | create | |
|