[3.13] gh-133167: Fix compilation process with --enable-optimizations and --without-docstrings (GH-133187) (#133207)

gh-133167: Fix compilation process with `--enable-optimizations` and `--without-docstrings` (GH-133187)
(cherry picked from commit cc39b19f0f)

Co-authored-by: sobolevn <mail@sobolevn.me>
This commit is contained in:
Miss Islington (bot) 2025-04-30 16:06:31 +02:00 committed by GitHub
parent 0458554482
commit 704a3f8c0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 5 deletions

View file

@ -1285,8 +1285,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")

View file

@ -2770,7 +2770,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)
@ -2862,7 +2862,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)
@ -3317,7 +3317,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):

View file

@ -603,6 +603,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)
@ -610,6 +611,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)
@ -617,6 +619,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)

View file

@ -0,0 +1,2 @@
Fix compilation process with ``--enable-optimizations`` and
``--without-docstrings``.