Skip to content

Commit 6c51c84

Browse files
authored
[3.11] gh-112266: Remove (if defined) part from __dict__ and __weakref__ docstrings (GH-112268) (#112276)
1 parent f6e11ea commit 6c51c84

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

Lib/test/test_pydoc.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class nonascii:
4040

4141
if test.support.HAVE_DOCSTRINGS:
4242
expected_data_docstrings = (
43-
'dictionary for instance variables (if defined)',
44-
'list of weak references to the object (if defined)',
43+
'dictionary for instance variables',
44+
'list of weak references to the object',
4545
) * 2
4646
else:
4747
expected_data_docstrings = ('', '', '', '')
@@ -105,10 +105,10 @@ class C(builtins.object)
105105
| Data descriptors defined here:
106106
|\x20\x20
107107
| __dict__
108-
| dictionary for instance variables (if defined)
108+
| dictionary for instance variables
109109
|\x20\x20
110110
| __weakref__
111-
| list of weak references to the object (if defined)
111+
| list of weak references to the object
112112
113113
FUNCTIONS
114114
doc_func()
@@ -166,16 +166,16 @@ class A(builtins.object)
166166
167167
Data descriptors defined here:
168168
__dict__
169-
dictionary for instance variables (if defined)
169+
dictionary for instance variables
170170
__weakref__
171-
list of weak references to the object (if defined)
171+
list of weak references to the object
172172
173173
class B(builtins.object)
174174
Data descriptors defined here:
175175
__dict__
176-
dictionary for instance variables (if defined)
176+
dictionary for instance variables
177177
__weakref__
178-
list of weak references to the object (if defined)
178+
list of weak references to the object
179179
Data and other attributes defined here:
180180
NO_MEANING = 'eggs'
181181
__annotations__ = {'NO_MEANING': <class 'str'>}
@@ -192,9 +192,9 @@ class C(builtins.object)
192192
__class_getitem__(item) from builtins.type
193193
Data descriptors defined here:
194194
__dict__
195-
dictionary for instance variables (if defined)
195+
dictionary for instance variables
196196
__weakref__
197-
list of weak references to the object (if defined)
197+
list of weak references to the object
198198
199199
Functions
200200
doc_func()
@@ -826,10 +826,10 @@ class B(A)
826826
| Data descriptors inherited from A:
827827
|\x20\x20
828828
| __dict__
829-
| dictionary for instance variables (if defined)
829+
| dictionary for instance variables
830830
|\x20\x20
831831
| __weakref__
832-
| list of weak references to the object (if defined)
832+
| list of weak references to the object
833833
''' % __name__)
834834

835835
doc = pydoc.render_doc(B, renderer=pydoc.HTMLDoc())
@@ -858,9 +858,9 @@ class B(A)
858858
859859
Data descriptors inherited from A:
860860
__dict__
861-
dictionary for instance variables (if defined)
861+
dictionary for instance variables
862862
__weakref__
863-
list of weak references to the object (if defined)
863+
list of weak references to the object
864864
"""
865865
as_text = html2text(doc)
866866
expected_lines = [line.strip() for line in expected_text.split("\n") if line]
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

+4-4
Original file line numberDiff line numberDiff line change
@@ -2399,21 +2399,21 @@ subtype_getweakref(PyObject *obj, void *context)
23992399

24002400
static PyGetSetDef subtype_getsets_full[] = {
24012401
{"__dict__", subtype_dict, subtype_setdict,
2402-
PyDoc_STR("dictionary for instance variables (if defined)")},
2402+
PyDoc_STR("dictionary for instance variables")},
24032403
{"__weakref__", subtype_getweakref, NULL,
2404-
PyDoc_STR("list of weak references to the object (if defined)")},
2404+
PyDoc_STR("list of weak references to the object")},
24052405
{0}
24062406
};
24072407

24082408
static PyGetSetDef subtype_getsets_dict_only[] = {
24092409
{"__dict__", subtype_dict, subtype_setdict,
2410-
PyDoc_STR("dictionary for instance variables (if defined)")},
2410+
PyDoc_STR("dictionary for instance variables")},
24112411
{0}
24122412
};
24132413

24142414
static PyGetSetDef subtype_getsets_weakref_only[] = {
24152415
{"__weakref__", subtype_getweakref, NULL,
2416-
PyDoc_STR("list of weak references to the object (if defined)")},
2416+
PyDoc_STR("list of weak references to the object")},
24172417
{0}
24182418
};
24192419

0 commit comments

Comments
 (0)