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.

Author skreft
Recipients benjamin.peterson, eric.smith, skreft, steven.daprano
Date 2018-06-30.16:21:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <[email protected]>
In-reply-to
Content
Note also, that lib2to3 will parse invalid f-strings like f"hello {", whereas ast.parse will raise a SyntaxError exception.


See below for reproduction cases:
In [2]: lib2to3.tests.support.parse_string('f"hello {"')
Out[2]: Node(file_input, [Node(simple_stmt, [Leaf(3, 'f"hello {"'), Leaf(4, '\n')]), Leaf(0, '')])

In [4]: ast.parse('f"hello {"')
Traceback (most recent call last):

  File "/Users/skreft/.virtualenvs/pyfaster/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2963, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-4-78a4f2773f7f>", line 1, in <module>
    ast.parse('f"hello {"')

  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ast.py", line 35, in parse
    return compile(source, filename, mode, PyCF_ONLY_AST)

  File "<unknown>", line 1
SyntaxError: f-string: expecting '}'
History
Date User Action Args
2018-06-30 16:21:18skreftsetrecipients: + skreft, eric.smith, benjamin.peterson, steven.daprano
2018-06-30 16:21:18skreftsetmessageid: <[email protected]>
2018-06-30 16:21:18skreftlinkissue33991 messages
2018-06-30 16:21:18skreftcreate