[New-bugs-announce] [issue33552] f-strings and string annotations
Serhiy Storchaka
report at bugs.python.org
Thu May 17 03:03:06 EDT 2018
New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:
There are problems with converting annotations containing f-strings into strings (from __future__ import annotations). For example f'''{"'"}''' is converted to f'{"\'"}', but the latter is a syntax error.
>>> from __future__ import annotations
>>> x: f'''{"'"}'''
>>> print(__annotations__['x'])
f'{"\'"}'
>>> x: f'{"\'"}'
File "<stdin>", line 1
SyntaxError: f-string expression part cannot include a backslash
More complex examples:
f"""{"'''"}"""
f"""{"'" '"'}"""
f"""{"'''"}""" f'''{'"""'}'''
----------
components: Interpreter Core
messages: 316886
nosy: eric.smith, lukasz.langa, serhiy.storchaka
priority: normal
severity: normal
status: open
title: f-strings and string annotations
type: behavior
versions: Python 3.7, Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33552>
_______________________________________
More information about the New-bugs-announce
mailing list