classification
Title: str.format() crashes
Type: crash Stage: resolved
Components: Interpreter Core, Unicode Versions: Python 3.4, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, eric.smith, ezio.melotti, haypo, mark.dickinson, poldnev, python-dev, serhiy.storchaka
Priority: high Keywords: 3.3regression, patch

Created on 2013-04-06 14:46 by poldnev, last changed 2013-05-17 23:23 by python-dev. This issue is now closed.

Files
File name Uploaded Description Edit
fix_format_spec.patch benjamin.peterson, 2013-04-06 17:12 review
fix_format_spec.patch benjamin.peterson, 2013-04-06 19:07 review
Messages (7)
msg186130 - (view) Author: Anton Poldnev (poldnev) Date: 2013-04-06 14:46
Windows interpreter immediately crashes on this command:
>>> "{[{}]}".format({"{}": 5})
msg186131 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2013-04-06 14:50
Confirmed on Linux too.  This only affects 3.3+, on 2.7/3.2 it returns '5'.
msg186140 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2013-04-06 17:12
Here is a patch, which fixes the issue. This brings up rather subtle issues. For example you can have "{[{}]}" but not "{[{]}" as a format string. I wonder if having braces in the field name at all should be an error.
msg186146 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2013-04-06 19:07
Here's a more comprehensive patch. It follows the PEP by allowing "{" and "}" inside "[]" in the field name.
msg186163 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2013-04-06 20:04
> I wonder if having braces in the field name at all should be an error.

There's some discussion of this in issue #12014;  e.g. msg137617.  I'm not sure what conclusion was reached.  Eric?
msg186211 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-04-07 14:36
The first patch looks better for me. It is simpler and I do not sure the thing is worth a complication.
msg189490 - (view) Author: Roundup Robot (python-dev) Date: 2013-05-17 23:23
New changeset 6786e681ed58 by Benjamin Peterson in branch '3.3':
only recursively expand in the format spec (closes #17644)
http://hg.python.org/cpython/rev/6786e681ed58
History
Date User Action Args
2013-05-17 23:23:06python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg189490

resolution: fixed
stage: patch review -> resolved
2013-04-07 14:37:09serhiy.storchakasetkeywords: + 3.3regression
2013-04-07 14:36:36serhiy.storchakasetmessages: + msg186211
stage: needs patch -> patch review
2013-04-06 20:04:20mark.dickinsonsetnosy: + mark.dickinson
messages: + msg186163
2013-04-06 19:07:15benjamin.petersonsetfiles: + fix_format_spec.patch

messages: + msg186146
2013-04-06 17:12:48benjamin.petersonsetfiles: + fix_format_spec.patch

nosy: + benjamin.peterson
messages: + msg186140

keywords: + patch
2013-04-06 14:50:29ezio.melottisetpriority: normal -> high

components: + Interpreter Core, Unicode
versions: + Python 3.4
nosy: + haypo, eric.smith, ezio.melotti, serhiy.storchaka

messages: + msg186131
stage: needs patch
2013-04-06 14:46:26poldnevcreate