New submission from Andrew Svetlov:
I think this is a bug.
Can be reproduced on all Pythons (from 2.6 to 3.4a).
Maybe should be fixed for 3.4 only as backward incompatible change.
--
messages: 195263
nosy: asvetlov
priority: normal
severity: normal
status: open
title: ''' % [1] doens't
R. David Murray added the comment:
What is it that doesn't fail? The expression in the title is the beginning of
a triple quoted string with no closing triple quote.
If you mean '' % [1] not falling, it has been that way forever (well, python2.4
is as far back as I can test), so if it is
STINNER Victor added the comment:
I don't understand why str % list and str % dict behaves differently than str %
int:
'abc' % [1]
'abc'
'abc' % ([1],)
Traceback (most recent call last):
File stdin, line 1, in module
TypeError: not all arguments converted during string formatting
'abc' %
R. David Murray added the comment:
haypo: str % dict is a feature:
%(a)s % {'a': 1, 'b': 2}
'1'
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18750
___
Andrew Svetlov added the comment:
For dict it is correct from my perspective.
% {'a': 'b'}
tries to substitute format specs like %(a)s and does nothing if spec is not
present.
But list case like
% [1]
confuse me.
--
___
Python tracker
R. David Murray added the comment:
Yes, I suspect you are right that that is a bug...and a long standing one :)
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18750
___
Eric V. Smith added the comment:
Objects/unicodeobject.c has this, at line 14316:
if (PyMapping_Check(args) !PyTuple_Check(args) !PyUnicode_Check(args))
ctx.dict = args;
else
ctx.dict = NULL;
and later at line 14348:
if (ctx.argidx ctx.arglen !ctx.dict) {