[3.9] bpo-41520: Fix second codeop regression (GH-21848)

Fix the repression introduced by the initial regression fix.

(cherry picked from commit c818b15fa5)
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This commit is contained in:
Terry Jan Reedy 2020-08-13 14:21:32 -04:00 committed by GitHub
parent b3ad2ca56a
commit f24430f154
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 8 deletions

View file

@ -306,14 +306,17 @@ class CodeopTests(unittest.TestCase):
def test_warning(self):
# Test that the warning is only returned once.
with support.check_warnings((".*literal", SyntaxWarning)) as w:
compile_command("0 is 0")
self.assertEqual(len(w.warnings), 1)
with support.check_warnings(
(".*literal", SyntaxWarning),
(".*invalid", DeprecationWarning),
) as w:
compile_command(r"'\e' is 0")
self.assertEqual(len(w.warnings), 2)
# bpo-41520: check SyntaxWarning treated as an SyntaxError
with self.assertRaises(SyntaxError):
with warnings.catch_warnings(), self.assertRaises(SyntaxError):
warnings.simplefilter('error', SyntaxWarning)
compile_command('1 is 1\n', symbol='exec')
compile_command('1 is 1', symbol='exec')
if __name__ == "__main__":