[Python-checkins] gh-105915: Add 'r' prefix to not emit SyntaxWarning in test_fstring (#105940)

lysnikolaou webhook-mailer at python.org
Tue Jun 20 08:49:04 EDT 2023


https://github.com/python/cpython/commit/4b431d2e90bf5760a57aa40af2dd78e7bbf0b1ae
commit: 4b431d2e90bf5760a57aa40af2dd78e7bbf0b1ae
branch: main
author: Lysandros Nikolaou <lisandrosnik at gmail.com>
committer: lysnikolaou <lisandrosnik at gmail.com>
date: 2023-06-20T14:49:00+02:00
summary:

gh-105915: Add 'r' prefix to not emit SyntaxWarning in test_fstring (#105940)

Co-authored-by: @sunmy2019

files:
M Lib/test/test_fstring.py

diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py
index ad5ac6a2f043..1eb3bfb41888 100644
--- a/Lib/test/test_fstring.py
+++ b/Lib/test/test_fstring.py
@@ -773,7 +773,7 @@ def __format__(self, format_spec):
         self.assertEqual(f'{CustomFormat():\n}', '\n')
         self.assertEqual(f'{CustomFormat():\u2603}', '☃')
         with self.assertWarns(SyntaxWarning):
-            exec('f"{F():¯\_(ツ)_/¯}"', {'F': CustomFormat})
+            exec(r'f"{F():¯\_(ツ)_/¯}"', {'F': CustomFormat})
 
     def test_side_effect_order(self):
         class X:



More information about the Python-checkins mailing list