Skip to content

[3.12] gh-112266: Remove (if defined) part from __dict__ and __weakref__ docstrings (GH-112268) #112270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions Lib/test/test_pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class nonascii:

if test.support.HAVE_DOCSTRINGS:
expected_data_docstrings = (
'dictionary for instance variables (if defined)',
'list of weak references to the object (if defined)',
'dictionary for instance variables',
'list of weak references to the object',
) * 2
else:
expected_data_docstrings = ('', '', '', '')
Expand Down Expand Up @@ -105,10 +105,10 @@ class C(builtins.object)
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object (if defined)
| list of weak references to the object

FUNCTIONS
doc_func()
Expand Down Expand Up @@ -166,16 +166,16 @@ class A(builtins.object)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
dictionary for instance variables
__weakref__
list of weak references to the object (if defined)
list of weak references to the object

class B(builtins.object)
Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
dictionary for instance variables
__weakref__
list of weak references to the object (if defined)
list of weak references to the object
Data and other attributes defined here:
NO_MEANING = 'eggs'
__annotations__ = {'NO_MEANING': <class 'str'>}
Expand All @@ -192,9 +192,9 @@ class C(builtins.object)
__class_getitem__(item) from builtins.type
Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
dictionary for instance variables
__weakref__
list of weak references to the object (if defined)
list of weak references to the object

Functions
doc_func()
Expand Down Expand Up @@ -826,10 +826,10 @@ class B(A)
| Data descriptors inherited from A:
|
| __dict__
| dictionary for instance variables (if defined)
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object (if defined)
| list of weak references to the object
''' % __name__)

doc = pydoc.render_doc(B, renderer=pydoc.HTMLDoc())
Expand Down Expand Up @@ -858,9 +858,9 @@ class B(A)

Data descriptors inherited from A:
__dict__
dictionary for instance variables (if defined)
dictionary for instance variables
__weakref__
list of weak references to the object (if defined)
list of weak references to the object
"""
as_text = html2text(doc)
expected_lines = [line.strip() for line in expected_text.split("\n") if line]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Change docstrings of :attr:`~object.__dict__` and
:attr:`~object.__weakref__`.
8 changes: 4 additions & 4 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2974,21 +2974,21 @@ subtype_getweakref(PyObject *obj, void *context)

static PyGetSetDef subtype_getsets_full[] = {
{"__dict__", subtype_dict, subtype_setdict,
PyDoc_STR("dictionary for instance variables (if defined)")},
PyDoc_STR("dictionary for instance variables")},
{"__weakref__", subtype_getweakref, NULL,
PyDoc_STR("list of weak references to the object (if defined)")},
PyDoc_STR("list of weak references to the object")},
{0}
};

static PyGetSetDef subtype_getsets_dict_only[] = {
{"__dict__", subtype_dict, subtype_setdict,
PyDoc_STR("dictionary for instance variables (if defined)")},
PyDoc_STR("dictionary for instance variables")},
{0}
};

static PyGetSetDef subtype_getsets_weakref_only[] = {
{"__weakref__", subtype_getweakref, NULL,
PyDoc_STR("list of weak references to the object (if defined)")},
PyDoc_STR("list of weak references to the object")},
{0}
};

Expand Down