From 4a37071fc30f0931a78f53e687fcab021c943938 Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Thu, 25 Aug 2022 18:54:26 +0100 Subject: [PATCH] gh-96276: suppress SyntaxWarning in test_compile --- Lib/test/test_compile.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index c64e4e55f4445a..d7b78f686ef88d 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -8,6 +8,7 @@ import tempfile import types import textwrap +import warnings from test import support from test.support import script_helper, requires_debug_ranges from test.support.os_helper import FakePath @@ -1231,7 +1232,9 @@ def f(): with self.subTest(body): namespace = {} source = textwrap.dedent(source_template.format(body)) - exec(source, namespace) + with warnings.catch_warnings(): + warnings.simplefilter('ignore', SyntaxWarning) + exec(source, namespace) code = namespace["f"].__code__ self.assertOpcodeSourcePositionIs( code,