Skip to content

Commit cf8c830

Browse files
[3.12] gh-112266: Remove (if defined) part from __dict__ and __weakref__ docstrings (GH-112268) (#112270)
gh-112266: Remove `(if defined)` part from `__dict__` and `__weakref__` docstrings (GH-112268) (cherry picked from commit f812914) Co-authored-by: Nikita Sobolev <[email protected]>
1 parent f521321 commit cf8c830

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
|
107107
| __dict__
108-
| dictionary for instance variables (if defined)
108+
| dictionary for instance variables
109109
|
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
|
828828
| __dict__
829-
| dictionary for instance variables (if defined)
829+
| dictionary for instance variables
830830
|
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
@@ -2974,21 +2974,21 @@ subtype_getweakref(PyObject *obj, void *context)
29742974

29752975
static PyGetSetDef subtype_getsets_full[] = {
29762976
{"__dict__", subtype_dict, subtype_setdict,
2977-
PyDoc_STR("dictionary for instance variables (if defined)")},
2977+
PyDoc_STR("dictionary for instance variables")},
29782978
{"__weakref__", subtype_getweakref, NULL,
2979-
PyDoc_STR("list of weak references to the object (if defined)")},
2979+
PyDoc_STR("list of weak references to the object")},
29802980
{0}
29812981
};
29822982

29832983
static PyGetSetDef subtype_getsets_dict_only[] = {
29842984
{"__dict__", subtype_dict, subtype_setdict,
2985-
PyDoc_STR("dictionary for instance variables (if defined)")},
2985+
PyDoc_STR("dictionary for instance variables")},
29862986
{0}
29872987
};
29882988

29892989
static PyGetSetDef subtype_getsets_weakref_only[] = {
29902990
{"__weakref__", subtype_getweakref, NULL,
2991-
PyDoc_STR("list of weak references to the object (if defined)")},
2991+
PyDoc_STR("list of weak references to the object")},
29922992
{0}
29932993
};
29942994

0 commit comments

Comments
 (0)