summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_fstring.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_fstring.py')
-rw-r--r--Lib/test/test_fstring.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py
index da0160d..27c7f70 100644
--- a/Lib/test/test_fstring.py
+++ b/Lib/test/test_fstring.py
@@ -8,6 +8,7 @@
# Unicode identifiers in tests is allowed by PEP 3131.
import ast
+import dis
import os
import re
import types
@@ -1738,5 +1739,14 @@ print(f'''{{
self.assertIn(rb'\1', stdout)
self.assertEqual(len(stderr.strip().splitlines()), 2)
+ def test_fstring_without_formatting_bytecode(self):
+ # f-string without any formatting should emit the same bytecode
+ # as a normal string. See gh-99606.
+ def get_code(s):
+ return [(i.opname, i.oparg) for i in dis.get_instructions(s)]
+
+ for s in ["", "some string"]:
+ self.assertEqual(get_code(f"'{s}'"), get_code(f"f'{s}'"))
+
if __name__ == '__main__':
unittest.main()