Skip to content

Commit 8616001

Browse files
committed
gh-112266: Remove (if defined) part from __dict__ and __weakref__ docstrings
1 parent 6bf8f20 commit 8616001

File tree

4 files changed

+30
-25
lines changed

4 files changed

+30
-25
lines changed

Lib/inspect.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,8 @@ def getfullargspec(func):
14031403
- the "self" parameter is always reported, even for bound methods
14041404
- wrapper chains defined by __wrapped__ *not* unwrapped automatically
14051405
"""
1406+
import warnings
1407+
warnings._deprecated("getfullargspect", "", removed=(3, 15))
14061408
try:
14071409
# Re: `skip_bound_arg=False`
14081410
#
@@ -1419,12 +1421,11 @@ def getfullargspec(func):
14191421
#
14201422
# getfullargspec() historically ignored __wrapped__ attributes,
14211423
# so we ensure that remains the case in 3.3+
1422-
1423-
sig = _signature_from_callable(func,
1424-
follow_wrapper_chains=False,
1425-
skip_bound_arg=False,
1426-
sigcls=Signature,
1427-
eval_str=False)
1424+
#
1425+
# See: https://github.com/python/cpython/issues/108901
1426+
sig = Signature.from_callable(func,
1427+
follow_wrapped=False,
1428+
skip_bound_arg=False)
14281429
except Exception as ex:
14291430
# Most of the times 'signature' will raise ValueError.
14301431
# But, it can also raise AttributeError, and, maybe something
@@ -3103,10 +3104,12 @@ def __init__(self, parameters=None, *, return_annotation=_empty,
31033104

31043105
@classmethod
31053106
def from_callable(cls, obj, *,
3106-
follow_wrapped=True, globals=None, locals=None, eval_str=False):
3107+
follow_wrapped=True, skip_bound_arg=True,
3108+
globals=None, locals=None, eval_str=False):
31073109
"""Constructs Signature for the given callable object."""
31083110
return _signature_from_callable(obj, sigcls=cls,
31093111
follow_wrapper_chains=follow_wrapped,
3112+
skip_bound_arg=skip_bound_arg,
31103113
globals=globals, locals=locals, eval_str=eval_str)
31113114

31123115
@property

Lib/test/test_pydoc.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ class nonascii:
4343

4444
if test.support.HAVE_DOCSTRINGS:
4545
expected_data_docstrings = (
46-
'dictionary for instance variables (if defined)',
47-
'list of weak references to the object (if defined)',
46+
'dictionary for instance variables',
47+
'list of weak references to the object',
4848
) * 2
4949
else:
5050
expected_data_docstrings = ('', '', '', '')
@@ -108,10 +108,10 @@ class C(builtins.object)
108108
| Data descriptors defined here:
109109
|
110110
| __dict__
111-
| dictionary for instance variables (if defined)
111+
| dictionary for instance variables
112112
|
113113
| __weakref__
114-
| list of weak references to the object (if defined)
114+
| list of weak references to the object
115115
116116
FUNCTIONS
117117
doc_func()
@@ -169,16 +169,16 @@ class A(builtins.object)
169169
170170
Data descriptors defined here:
171171
__dict__
172-
dictionary for instance variables (if defined)
172+
dictionary for instance variables
173173
__weakref__
174-
list of weak references to the object (if defined)
174+
list of weak references to the object
175175
176176
class B(builtins.object)
177177
Data descriptors defined here:
178178
__dict__
179-
dictionary for instance variables (if defined)
179+
dictionary for instance variables
180180
__weakref__
181-
list of weak references to the object (if defined)
181+
list of weak references to the object
182182
Data and other attributes defined here:
183183
NO_MEANING = 'eggs'
184184
__annotations__ = {'NO_MEANING': <class 'str'>}
@@ -195,9 +195,9 @@ class C(builtins.object)
195195
__class_getitem__(item) from builtins.type
196196
Data descriptors defined here:
197197
__dict__
198-
dictionary for instance variables (if defined)
198+
dictionary for instance variables
199199
__weakref__
200-
list of weak references to the object (if defined)
200+
list of weak references to the object
201201
202202
Functions
203203
doc_func()
@@ -829,10 +829,10 @@ class B(A)
829829
| Data descriptors inherited from A:
830830
|
831831
| __dict__
832-
| dictionary for instance variables (if defined)
832+
| dictionary for instance variables
833833
|
834834
| __weakref__
835-
| list of weak references to the object (if defined)
835+
| list of weak references to the object
836836
''' % __name__)
837837

838838
doc = pydoc.render_doc(B, renderer=pydoc.HTMLDoc())
@@ -861,9 +861,9 @@ class B(A)
861861
862862
Data descriptors inherited from A:
863863
__dict__
864-
dictionary for instance variables (if defined)
864+
dictionary for instance variables
865865
__weakref__
866-
list of weak references to the object (if defined)
866+
list of weak references to the object
867867
"""
868868
as_text = html2text(doc)
869869
expected_lines = [line.strip() for line in expected_text.split("\n") if line]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Change docstrings of :attr:`~object.__dict__` and
2+
:attr:`~object.__weakref__`.

Objects/typeobject.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3006,21 +3006,21 @@ subtype_getweakref(PyObject *obj, void *context)
30063006

30073007
static PyGetSetDef subtype_getsets_full[] = {
30083008
{"__dict__", subtype_dict, subtype_setdict,
3009-
PyDoc_STR("dictionary for instance variables (if defined)")},
3009+
PyDoc_STR("dictionary for instance variables")},
30103010
{"__weakref__", subtype_getweakref, NULL,
3011-
PyDoc_STR("list of weak references to the object (if defined)")},
3011+
PyDoc_STR("list of weak references to the object")},
30123012
{0}
30133013
};
30143014

30153015
static PyGetSetDef subtype_getsets_dict_only[] = {
30163016
{"__dict__", subtype_dict, subtype_setdict,
3017-
PyDoc_STR("dictionary for instance variables (if defined)")},
3017+
PyDoc_STR("dictionary for instance variables")},
30183018
{0}
30193019
};
30203020

30213021
static PyGetSetDef subtype_getsets_weakref_only[] = {
30223022
{"__weakref__", subtype_getweakref, NULL,
3023-
PyDoc_STR("list of weak references to the object (if defined)")},
3023+
PyDoc_STR("list of weak references to the object")},
30243024
{0}
30253025
};
30263026

0 commit comments

Comments
 (0)