classification
Title: Inconsistent behaviour of PEP 3101 formatting between versions
Type: behavior Stage:
Components: Interpreter Core Versions: Python 3.4
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: deleted0524, eric.smith
Priority: normal Keywords:

Created on 2016-02-03 11:39 by deleted0524, last changed 2016-02-03 12:29 by eric.smith.

Messages (2)
msg259473 - (view) Author: deleted0524 (deleted0524) Date: 2016-02-03 11:39
In Python 2.7.6 and 3.2.3:
>>> "{ {{ 0} }}".format(**{' {{ 0} }': 'X'})
'X'

In Python 3.4.3:
>>> "{ {{ 0} }}".format(**{' {{ 0} }': 'X'})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: unexpected '{' in field name


I think the problem is that PEP 3101 is under specified w.r.t. to non identifier characters in format units.
msg259478 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2016-02-03 12:29
Hi, Mark.

Yes, PEP 3101 is very much under-specified in this area. I tried to avoid the same mistake in PEP 498, although of course that's a different problem area.

I don't recall why this particular case broke between 3.2.3 and 3.4.3. I'll try and track it down. I'm sure we were trying to "fix" some other edge condition.

FWIW, in 3.4.3 this also fails, as expected:
>>> "{ {{ 0} }}".format_map({' {{ 0} }': 'X'})

Can you try it in 3.2.3? I expect it to work, but you never know.
History
Date User Action Args
2016-02-03 12:29:20eric.smithsetmessages: + msg259478
2016-02-03 12:23:51eric.smithsetnosy: + eric.smith
2016-02-03 11:39:10deleted0524create