This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Inconsistent behaviour of PEP 3101 formatting between versions
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: deleted0524, eric.smith, iritkatriel
Priority: normal Keywords:

Created on 2016-02-03 11:39 by deleted0524, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
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.
msg411533 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-01-25 00:03
Reproduced on 3.11.
msg412232 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2022-02-01 01:28
I'm going to close this issue. The behavior might be inconsistent with 2.7, but I don't think that matters any more.
History
Date User Action Args
2022-04-11 14:58:27adminsetgithub: 70464
2022-02-01 01:28:46eric.smithsetstatus: open -> closed
resolution: wont fix
messages: + msg412232

stage: resolved
2022-01-25 00:03:49iritkatrielsetnosy: + iritkatriel

messages: + msg411533
versions: + Python 3.9, Python 3.10, Python 3.11, - Python 3.4
2016-02-03 12:29:20eric.smithsetmessages: + msg259478
2016-02-03 12:23:51eric.smithsetnosy: + eric.smith
2016-02-03 11:39:10deleted0524create