Skip to content

Commit cc39b19

Browse files
authored
gh-133167: Fix compilation process with --enable-optimizations and --without-docstrings (#133187)
1 parent 8b26b23 commit cc39b19

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

Lib/test/support/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1332,8 +1332,8 @@ def _check_docstrings():
13321332
sys.platform != 'win32' and
13331333
not sysconfig.get_config_var('WITH_DOC_STRINGS'))
13341334

1335-
HAVE_DOCSTRINGS = (_check_docstrings.__doc__ is not None and
1336-
not MISSING_C_DOCSTRINGS)
1335+
HAVE_PY_DOCSTRINGS = _check_docstrings.__doc__ is not None
1336+
HAVE_DOCSTRINGS = (HAVE_PY_DOCSTRINGS and not MISSING_C_DOCSTRINGS)
13371337

13381338
requires_docstrings = unittest.skipUnless(HAVE_DOCSTRINGS,
13391339
"test requires docstrings")

Lib/test/test_functools.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2952,7 +2952,7 @@ def static_func(arg: int) -> str:
29522952
self.assertEqual(meth.__qualname__, prefix + meth.__name__)
29532953
self.assertEqual(meth.__doc__,
29542954
('My function docstring'
2955-
if support.HAVE_DOCSTRINGS
2955+
if support.HAVE_PY_DOCSTRINGS
29562956
else None))
29572957
self.assertEqual(meth.__annotations__['arg'], int)
29582958

@@ -3107,7 +3107,7 @@ def decorated_classmethod(cls, arg: int) -> str:
31073107
with self.subTest(meth=meth):
31083108
self.assertEqual(meth.__doc__,
31093109
('My function docstring'
3110-
if support.HAVE_DOCSTRINGS
3110+
if support.HAVE_PY_DOCSTRINGS
31113111
else None))
31123112
self.assertEqual(meth.__annotations__['arg'], int)
31133113

@@ -3584,7 +3584,7 @@ def test_access_from_class(self):
35843584
def test_doc(self):
35853585
self.assertEqual(CachedCostItem.cost.__doc__,
35863586
("The cost of the item."
3587-
if support.HAVE_DOCSTRINGS
3587+
if support.HAVE_PY_DOCSTRINGS
35883588
else None))
35893589

35903590
def test_module(self):

Lib/test/test_operator.py

+3
Original file line numberDiff line numberDiff line change
@@ -636,20 +636,23 @@ def test_dunder_is_original(self):
636636
if dunder:
637637
self.assertIs(dunder, orig)
638638

639+
@support.requires_docstrings
639640
def test_attrgetter_signature(self):
640641
operator = self.module
641642
sig = inspect.signature(operator.attrgetter)
642643
self.assertEqual(str(sig), '(attr, /, *attrs)')
643644
sig = inspect.signature(operator.attrgetter('x', 'z', 'y'))
644645
self.assertEqual(str(sig), '(obj, /)')
645646

647+
@support.requires_docstrings
646648
def test_itemgetter_signature(self):
647649
operator = self.module
648650
sig = inspect.signature(operator.itemgetter)
649651
self.assertEqual(str(sig), '(item, /, *items)')
650652
sig = inspect.signature(operator.itemgetter(2, 3, 5))
651653
self.assertEqual(str(sig), '(obj, /)')
652654

655+
@support.requires_docstrings
653656
def test_methodcaller_signature(self):
654657
operator = self.module
655658
sig = inspect.signature(operator.methodcaller)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix compilation process with ``--enable-optimizations`` and
2+
``--without-docstrings``.

0 commit comments

Comments
 (0)