summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-12-11 17:39:36 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-12-11 17:39:36 (GMT)
commit0f6373c34f5c0881d6ab2329aea5bce742789b20 (patch)
tree67470506d05cf6bff1d25067fc7068084a601a65 /Lib
parent26817a84908b831d71dd59de432f75829a5bae33 (diff)
parent4cc30ae31341ba233a861899be7d225519c71830 (diff)
downloadcpython-0f6373c34f5c0881d6ab2329aea5bce742789b20.zip
cpython-0f6373c34f5c0881d6ab2329aea5bce742789b20.tar.gz
cpython-0f6373c34f5c0881d6ab2329aea5bce742789b20.tar.bz2
Issue #28739: f-string expressions no longer accepted as docstrings and
by ast.literal_eval() even if they do not include subexpressions.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_fstring.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py
index 8205083..708ed25 100644
--- a/Lib/test/test_fstring.py
+++ b/Lib/test/test_fstring.py
@@ -70,18 +70,18 @@ f'{a * x()}'"""
# Make sure x was called.
self.assertTrue(x.called)
- def test_literal_eval(self):
- # With no expressions, an f-string is okay.
- self.assertEqual(ast.literal_eval("f'x'"), 'x')
- self.assertEqual(ast.literal_eval("f'x' 'y'"), 'xy')
-
- # But this should raise an error.
- with self.assertRaisesRegex(ValueError, 'malformed node or string'):
- ast.literal_eval("f'x{3}'")
+ def test_docstring(self):
+ def f():
+ f'''Not a docstring'''
+ self.assertIsNone(f.__doc__)
+ def g():
+ '''Not a docstring''' \
+ f''
+ self.assertIsNone(g.__doc__)
- # As should this, which uses a different ast node
+ def test_literal_eval(self):
with self.assertRaisesRegex(ValueError, 'malformed node or string'):
- ast.literal_eval("f'{3}'")
+ ast.literal_eval("f'x'")
def test_ast_compile_time_concat(self):
x = ['']