mirror of
https://github.com/python/cpython.git
synced 2025-11-09 10:01:42 +00:00
[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:
parent
0458554482
commit
704a3f8c0a
4 changed files with 10 additions and 5 deletions
|
|
@ -1285,8 +1285,8 @@ def _check_docstrings():
|
||||||
sys.platform != 'win32' and
|
sys.platform != 'win32' and
|
||||||
not sysconfig.get_config_var('WITH_DOC_STRINGS'))
|
not sysconfig.get_config_var('WITH_DOC_STRINGS'))
|
||||||
|
|
||||||
HAVE_DOCSTRINGS = (_check_docstrings.__doc__ is not None and
|
HAVE_PY_DOCSTRINGS = _check_docstrings.__doc__ is not None
|
||||||
not MISSING_C_DOCSTRINGS)
|
HAVE_DOCSTRINGS = (HAVE_PY_DOCSTRINGS and not MISSING_C_DOCSTRINGS)
|
||||||
|
|
||||||
requires_docstrings = unittest.skipUnless(HAVE_DOCSTRINGS,
|
requires_docstrings = unittest.skipUnless(HAVE_DOCSTRINGS,
|
||||||
"test requires docstrings")
|
"test requires docstrings")
|
||||||
|
|
|
||||||
|
|
@ -2770,7 +2770,7 @@ def static_func(arg: int) -> str:
|
||||||
self.assertEqual(meth.__qualname__, prefix + meth.__name__)
|
self.assertEqual(meth.__qualname__, prefix + meth.__name__)
|
||||||
self.assertEqual(meth.__doc__,
|
self.assertEqual(meth.__doc__,
|
||||||
('My function docstring'
|
('My function docstring'
|
||||||
if support.HAVE_DOCSTRINGS
|
if support.HAVE_PY_DOCSTRINGS
|
||||||
else None))
|
else None))
|
||||||
self.assertEqual(meth.__annotations__['arg'], int)
|
self.assertEqual(meth.__annotations__['arg'], int)
|
||||||
|
|
||||||
|
|
@ -2862,7 +2862,7 @@ def decorated_classmethod(cls, arg: int) -> str:
|
||||||
with self.subTest(meth=meth):
|
with self.subTest(meth=meth):
|
||||||
self.assertEqual(meth.__doc__,
|
self.assertEqual(meth.__doc__,
|
||||||
('My function docstring'
|
('My function docstring'
|
||||||
if support.HAVE_DOCSTRINGS
|
if support.HAVE_PY_DOCSTRINGS
|
||||||
else None))
|
else None))
|
||||||
self.assertEqual(meth.__annotations__['arg'], int)
|
self.assertEqual(meth.__annotations__['arg'], int)
|
||||||
|
|
||||||
|
|
@ -3317,7 +3317,7 @@ def test_access_from_class(self):
|
||||||
def test_doc(self):
|
def test_doc(self):
|
||||||
self.assertEqual(CachedCostItem.cost.__doc__,
|
self.assertEqual(CachedCostItem.cost.__doc__,
|
||||||
("The cost of the item."
|
("The cost of the item."
|
||||||
if support.HAVE_DOCSTRINGS
|
if support.HAVE_PY_DOCSTRINGS
|
||||||
else None))
|
else None))
|
||||||
|
|
||||||
def test_module(self):
|
def test_module(self):
|
||||||
|
|
|
||||||
|
|
@ -603,6 +603,7 @@ def test_dunder_is_original(self):
|
||||||
if dunder:
|
if dunder:
|
||||||
self.assertIs(dunder, orig)
|
self.assertIs(dunder, orig)
|
||||||
|
|
||||||
|
@support.requires_docstrings
|
||||||
def test_attrgetter_signature(self):
|
def test_attrgetter_signature(self):
|
||||||
operator = self.module
|
operator = self.module
|
||||||
sig = inspect.signature(operator.attrgetter)
|
sig = inspect.signature(operator.attrgetter)
|
||||||
|
|
@ -610,6 +611,7 @@ def test_attrgetter_signature(self):
|
||||||
sig = inspect.signature(operator.attrgetter('x', 'z', 'y'))
|
sig = inspect.signature(operator.attrgetter('x', 'z', 'y'))
|
||||||
self.assertEqual(str(sig), '(obj, /)')
|
self.assertEqual(str(sig), '(obj, /)')
|
||||||
|
|
||||||
|
@support.requires_docstrings
|
||||||
def test_itemgetter_signature(self):
|
def test_itemgetter_signature(self):
|
||||||
operator = self.module
|
operator = self.module
|
||||||
sig = inspect.signature(operator.itemgetter)
|
sig = inspect.signature(operator.itemgetter)
|
||||||
|
|
@ -617,6 +619,7 @@ def test_itemgetter_signature(self):
|
||||||
sig = inspect.signature(operator.itemgetter(2, 3, 5))
|
sig = inspect.signature(operator.itemgetter(2, 3, 5))
|
||||||
self.assertEqual(str(sig), '(obj, /)')
|
self.assertEqual(str(sig), '(obj, /)')
|
||||||
|
|
||||||
|
@support.requires_docstrings
|
||||||
def test_methodcaller_signature(self):
|
def test_methodcaller_signature(self):
|
||||||
operator = self.module
|
operator = self.module
|
||||||
sig = inspect.signature(operator.methodcaller)
|
sig = inspect.signature(operator.methodcaller)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix compilation process with ``--enable-optimizations`` and
|
||||||
|
``--without-docstrings``.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue