https://github.com/python/cpython/commit/3fd72d99ab23adab548c41e6f6dc1dc33805b8a2
commit: 3fd72d99ab23adab548c41e6f6dc1dc33805b8a2
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2024-02-19T17:17:53Z
summary:

[3.12] Fix test_compile with -O mode (GH-115346) (GH-115668)

(cherry picked from commit 7b25a82e83ad8fe15e4302bb7655309573affa83)

Co-authored-by: Serhiy Storchaka <[email protected]>

files:
M Lib/test/test_compile.py

diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index ed23d31c0d3ecd..815800f4e2f530 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -722,7 +722,7 @@ def f():
                 return "unused"
 
         self.assertEqual(f.__code__.co_consts,
-                         ("docstring", "used"))
+                         (f.__doc__, "used"))
 
     @support.cpython_only
     def test_remove_unused_consts_no_docstring(self):
@@ -767,7 +767,7 @@ def test_strip_unused_None(self):
         def f1():
             "docstring"
             return 42
-        self.assertEqual(f1.__code__.co_consts, ("docstring", 42))
+        self.assertEqual(f1.__code__.co_consts, (f1.__doc__, 42))
 
     # This is a regression test for a CPython specific peephole optimizer
     # implementation bug present in a few releases.  It's assertion verifies
@@ -996,6 +996,8 @@ def no_code2():
 
         for func in (no_code1, no_code2):
             with self.subTest(func=func):
+                if func is no_code1 and no_code1.__doc__ is None:
+                    continue
                 code = func.__code__
                 [(start, end, line)] = code.co_lines()
                 self.assertEqual(start, 0)
@@ -1394,6 +1396,7 @@ def test_multiline_boolean_expression(self):
         self.assertOpcodeSourcePositionIs(compiled_code, 'POP_JUMP_IF_TRUE',
             line=4, end_line=4, column=8, end_column=13, occurrence=2)
 
+    @unittest.skipIf(sys.flags.optimize, "Assertions are disabled in optimized 
mode")
     def test_multiline_assert(self):
         snippet = textwrap.dedent("""\
             assert (a > 0 and

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to