]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] Fix test_compile with -O mode (GH-115346) (GH-115673)
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 19 Feb 2024 18:06:13 +0000 (20:06 +0200)
committerGitHub <noreply@github.com>
Mon, 19 Feb 2024 18:06:13 +0000 (18:06 +0000)
(cherry picked from commit 7b25a82e83ad8fe15e4302bb7655309573affa83)

Lib/test/test_compile.py

index 408064919b0b49f020a1cd9bd2bc42d5a5997766..7b0a512f2800d2df52dadca6a99007f71a170a86 100644 (file)
@@ -704,7 +704,7 @@ if 1:
         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
@@ -935,6 +935,8 @@ if 1:
 
         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__
                 lines = list(code.co_lines())
                 start, end, line = lines[0]