Skip to content

Commit f812914

Browse files
authored
gh-112266: Remove (if defined) part from __dict__ and __weakref__ docstrings (#112268)
1 parent 77d9f1e commit f812914

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

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)