Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

str.format() crashes #61844

Closed
poldnev mannequin opened this issue Apr 6, 2013 · 7 comments
Closed

str.format() crashes #61844

poldnev mannequin opened this issue Apr 6, 2013 · 7 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-unicode type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@poldnev
Copy link
Mannequin

poldnev mannequin commented Apr 6, 2013

BPO 17644
Nosy @mdickinson, @vstinner, @ericvsmith, @benjaminp, @ezio-melotti, @serhiy-storchaka
Files
  • fix_format_spec.patch
  • fix_format_spec.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2013-05-17.23:23:06.719>
    created_at = <Date 2013-04-06.14:46:26.321>
    labels = ['interpreter-core', 'expert-unicode', 'type-crash']
    title = 'str.format() crashes'
    updated_at = <Date 2013-05-17.23:23:06.717>
    user = 'https://bugs.python.org/poldnev'

    bugs.python.org fields:

    activity = <Date 2013-05-17.23:23:06.717>
    actor = 'python-dev'
    assignee = 'none'
    closed = True
    closed_date = <Date 2013-05-17.23:23:06.719>
    closer = 'python-dev'
    components = ['Interpreter Core', 'Unicode']
    creation = <Date 2013-04-06.14:46:26.321>
    creator = 'poldnev'
    dependencies = []
    files = ['29691', '29693']
    hgrepos = []
    issue_num = 17644
    keywords = ['patch', '3.3regression']
    message_count = 7.0
    messages = ['186130', '186131', '186140', '186146', '186163', '186211', '189490']
    nosy_count = 8.0
    nosy_names = ['mark.dickinson', 'vstinner', 'eric.smith', 'benjamin.peterson', 'ezio.melotti', 'python-dev', 'serhiy.storchaka', 'poldnev']
    pr_nums = []
    priority = 'high'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue17644'
    versions = ['Python 3.3', 'Python 3.4']

    @poldnev
    Copy link
    Mannequin Author

    poldnev mannequin commented Apr 6, 2013

    Windows interpreter immediately crashes on this command:
    >>> "{[{}]}".format({"{}": 5})

    @poldnev poldnev mannequin added the type-crash A hard crash of the interpreter, possibly with a core dump label Apr 6, 2013
    @ezio-melotti
    Copy link
    Member

    Confirmed on Linux too. This only affects 3.3+, on 2.7/3.2 it returns '5'.

    @ezio-melotti ezio-melotti added interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-unicode labels Apr 6, 2013
    @benjaminp
    Copy link
    Contributor

    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.

    @benjaminp
    Copy link
    Contributor

    Here's a more comprehensive patch. It follows the PEP by allowing "{" and "}" inside "[]" in the field name.

    @mdickinson
    Copy link
    Member

    I wonder if having braces in the field name at all should be an error.

    There's some discussion of this in issue bpo-12014; e.g. msg137617. I'm not sure what conclusion was reached. Eric?

    @serhiy-storchaka
    Copy link
    Member

    The first patch looks better for me. It is simpler and I do not sure the thing is worth a complication.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 17, 2013

    New changeset 6786e681ed58 by Benjamin Peterson in branch '3.3':
    only recursively expand in the format spec (closes bpo-17644)
    http://hg.python.org/cpython/rev/6786e681ed58

    @python-dev python-dev mannequin closed this as completed May 17, 2013
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-unicode type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants