New submission from Serhiy Storchaka <storchaka+cpyt...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue33552>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to