[ python-Bugs-1539955 ] Insane format string should cause ValueError

SourceForge.net noreply at sourceforge.net
Mon Aug 14 14:14:35 CEST 2006


Bugs item #1539955, was opened at 2006-08-14 22:14
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1539955&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Submitted By: Nick Coghlan (ncoghlan)
Assigned to: Nobody/Anonymous (nobody)
Summary: Insane format string should cause ValueError

Initial Comment:
The documentation explicitly disallows mixing
positional string interpolation and named string
interpolation, but the following fails to raise an error:

>>> "%s%(red)s" % dict(red=1, blue=2)
"{'blue': 2, 'red': 1}1"

Turning it around results in the wrong *kind* of error:

>>> "%(red)s%s" % dict(red=1, blue=2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: not enough arguments for format string

A format string that mixes named and unnamed conversion
specifiers should trigger a ValueError.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1539955&group_id=5470


More information about the Python-bugs-list mailing list