mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
[3.12] gh-128772: Fix pydoc for methods with __module__ is None (GH-129177) (GH-129654)
(cherry picked from commit 979d766209)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
676ee57bd6
commit
0d207c3dd1
4 changed files with 16 additions and 1 deletions
|
|
@ -210,7 +210,7 @@ def parentname(object, modname):
|
|||
if necessary) or module."""
|
||||
if '.' in object.__qualname__:
|
||||
name = object.__qualname__.rpartition('.')[0]
|
||||
if object.__module__ != modname:
|
||||
if object.__module__ != modname and object.__module__ is not None:
|
||||
return object.__module__ + '.' + name
|
||||
else:
|
||||
return name
|
||||
|
|
|
|||
8
Lib/test/test_pydoc/module_none.py
Normal file
8
Lib/test/test_pydoc/module_none.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
def func():
|
||||
pass
|
||||
func.__module__ = None
|
||||
|
||||
class A:
|
||||
def method(self):
|
||||
pass
|
||||
method.__module__ = None
|
||||
|
|
@ -1592,6 +1592,11 @@ def a_fn_with_https_link():
|
|||
html
|
||||
)
|
||||
|
||||
def test_module_none(self):
|
||||
# Issue #128772
|
||||
from test.test_pydoc import module_none
|
||||
pydoc.render_doc(module_none)
|
||||
|
||||
|
||||
class PydocFodderTest(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
Fix :mod:`pydoc` for methods with the ``__module__`` attribute equal to
|
||||
``None``.
|
||||
Loading…
Add table
Add a link
Reference in a new issue