]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-133167: Fix compilation process with `--enable-optimizations` and `--without-docst...
authorsobolevn <mail@sobolevn.me>
Wed, 30 Apr 2025 13:41:50 +0000 (16:41 +0300)
committerGitHub <noreply@github.com>
Wed, 30 Apr 2025 13:41:50 +0000 (16:41 +0300)
Lib/test/support/__init__.py
Lib/test/test_functools.py
Lib/test/test_operator.py
Misc/NEWS.d/next/Build/2025-04-30-10-23-18.gh-issue-133167.E0jrYJ.rst [new file with mode: 0644]

index 82f881094982f6c7274a72d8ed6686c50c990847..24984ad81fff991f7a00bb8e15a2e1bdbc870ee7 100644 (file)
@@ -1332,8 +1332,8 @@ MISSING_C_DOCSTRINGS = (check_impl_detail() and
                         sys.platform != 'win32' and
                         not sysconfig.get_config_var('WITH_DOC_STRINGS'))
 
-HAVE_DOCSTRINGS = (_check_docstrings.__doc__ is not None and
-                   not MISSING_C_DOCSTRINGS)
+HAVE_PY_DOCSTRINGS = _check_docstrings.__doc__ is not None
+HAVE_DOCSTRINGS = (HAVE_PY_DOCSTRINGS and not MISSING_C_DOCSTRINGS)
 
 requires_docstrings = unittest.skipUnless(HAVE_DOCSTRINGS,
                                           "test requires docstrings")
index 4794a7465f0b6629feb80a969693cbbbf41a793c..e3b449f2d24a2b63e99231cd84a249047f977534 100644 (file)
@@ -2952,7 +2952,7 @@ class TestSingleDispatch(unittest.TestCase):
                 self.assertEqual(meth.__qualname__, prefix + meth.__name__)
                 self.assertEqual(meth.__doc__,
                                  ('My function docstring'
-                                  if support.HAVE_DOCSTRINGS
+                                  if support.HAVE_PY_DOCSTRINGS
                                   else None))
                 self.assertEqual(meth.__annotations__['arg'], int)
 
@@ -3107,7 +3107,7 @@ class TestSingleDispatch(unittest.TestCase):
             with self.subTest(meth=meth):
                 self.assertEqual(meth.__doc__,
                                  ('My function docstring'
-                                  if support.HAVE_DOCSTRINGS
+                                  if support.HAVE_PY_DOCSTRINGS
                                   else None))
                 self.assertEqual(meth.__annotations__['arg'], int)
 
@@ -3584,7 +3584,7 @@ class TestCachedProperty(unittest.TestCase):
     def test_doc(self):
         self.assertEqual(CachedCostItem.cost.__doc__,
                          ("The cost of the item."
-                          if support.HAVE_DOCSTRINGS
+                          if support.HAVE_PY_DOCSTRINGS
                           else None))
 
     def test_module(self):
index 1757824580e41669b6a5f19bd4cac26bd77d1107..1f89986c777ced836ba4b93ecef4126c726e6c0b 100644 (file)
@@ -636,6 +636,7 @@ class OperatorTestCase:
             if dunder:
                 self.assertIs(dunder, orig)
 
+    @support.requires_docstrings
     def test_attrgetter_signature(self):
         operator = self.module
         sig = inspect.signature(operator.attrgetter)
@@ -643,6 +644,7 @@ class OperatorTestCase:
         sig = inspect.signature(operator.attrgetter('x', 'z', 'y'))
         self.assertEqual(str(sig), '(obj, /)')
 
+    @support.requires_docstrings
     def test_itemgetter_signature(self):
         operator = self.module
         sig = inspect.signature(operator.itemgetter)
@@ -650,6 +652,7 @@ class OperatorTestCase:
         sig = inspect.signature(operator.itemgetter(2, 3, 5))
         self.assertEqual(str(sig), '(obj, /)')
 
+    @support.requires_docstrings
     def test_methodcaller_signature(self):
         operator = self.module
         sig = inspect.signature(operator.methodcaller)
diff --git a/Misc/NEWS.d/next/Build/2025-04-30-10-23-18.gh-issue-133167.E0jrYJ.rst b/Misc/NEWS.d/next/Build/2025-04-30-10-23-18.gh-issue-133167.E0jrYJ.rst
new file mode 100644 (file)
index 0000000..ee6d5a3
--- /dev/null
@@ -0,0 +1,2 @@
+Fix compilation process with ``--enable-optimizations`` and
+``--without-docstrings``.