Closed
Description
Bug report
Bug description:
Steps to reproduce:
- Create a module (
testmodule.py
):from warnings import deprecated @deprecated("Test") class A: pass
- In the Python shell, run:
import testmodule help(testmodule)
This will raise a TypeError
:
File "/fakepath/uv/python/cpython-3.13.1-linux-x86_64-gnu/lib/python3.13/pydoc.py", line 245, in parentname
return object.__module__ + '.' + name
~~~~~~~~~~~~~~~~~~^~~~~
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
warnings.deprecated
is defining custom __new__
and __init_subclass__
methods:
Lines 588 to 615 in 6e1e780
and because these methods don't have a __module__
available (maybe they should?), we end up with the above exception.
Should we special case deprecated classes and other objects using the warnings.deprecated
decorator in pydoc to display specific information? I don't think it's relevant to show the __new__
and __init_subclass__
overridden methods in the documentation output.
CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs
- gh-128772: Fix - warnings.deprecated doesn't work well with pydoc #128781
- gh-128772: Fix pydoc for methods with __module__ is None #129177
- [3.13] gh-128772: Fix pydoc for methods with __module__ is None (GH-129177) #129653
- [3.12] gh-128772: Fix pydoc for methods with __module__ is None (GH-129177) #129654
- [3.13] gh-128772: Fix pydoc for methods with __module__ is None (GH-129177) #129655