Skip to content

Commit 8b849ea

Browse files
authored
bpo-38291: Fix a spurious warning when using help(object) (#27039)
help(object) via pydoc.TextDoc.docclass(object) iterates over the subclasses of object, which includes typing.io and typing.re if typing is imported. It tries to access cls.__module__ for each of those sub-classes. This change suppresses warnings when accessing cls.__module__.
1 parent f64de53 commit 8b849ea

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Lib/typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2512,7 +2512,7 @@ def __enter__(self) -> 'TextIO':
25122512

25132513
class _DeprecatedType(type):
25142514
def __getattribute__(cls, name):
2515-
if name != "__dict__" and name in cls.__dict__:
2515+
if name not in ("__dict__", "__module__") and name in cls.__dict__:
25162516
warnings.warn(
25172517
f"{cls.__name__} is deprecated, import directly "
25182518
f"from typing instead. {cls.__name__} will be removed "

0 commit comments

Comments
 (0)