skreft <skr...@gmail.com> added the comment:
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 '}' ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33991> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com