diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-06-02 12:53:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-02 12:53:27 (GMT) |
commit | 103ae4e36e965b2d693c90bb6cb699f845903950 (patch) | |
tree | 21fbd59a501b94c8c0db63b7099b94ca590189dd /Lib | |
parent | 46cc4f0f76a9f6966aee76d74f8db9a2f43fa8a6 (diff) | |
download | cpython-103ae4e36e965b2d693c90bb6cb699f845903950.zip cpython-103ae4e36e965b2d693c90bb6cb699f845903950.tar.gz cpython-103ae4e36e965b2d693c90bb6cb699f845903950.tar.bz2 |
[3.12] gh-105194: Fix format specifier escaped characters in f-strings (GH-105231) (#105234)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_fstring.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py index 3ba2f94..031b94d 100644 --- a/Lib/test/test_fstring.py +++ b/Lib/test/test_fstring.py @@ -764,6 +764,16 @@ x = ( """f'{"s"!{"r"}}'""", ]) + def test_custom_format_specifier(self): + class CustomFormat: + def __format__(self, format_spec): + return format_spec + + self.assertEqual(f'{CustomFormat():\n}', '\n') + self.assertEqual(f'{CustomFormat():\u2603}', '☃') + with self.assertWarns(SyntaxWarning): + exec('f"{F():¯\_(ツ)_/¯}"', {'F': CustomFormat}) + def test_side_effect_order(self): class X: def __init__(self): |