]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38291: Fix a spurious warning when using help(object) (#27039)
authorSebastian Rittau <srittau@rittau.biz>
Tue, 6 Jul 2021 15:01:15 +0000 (17:01 +0200)
committerGitHub <noreply@github.com>
Tue, 6 Jul 2021 15:01:15 +0000 (08:01 -0700)
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__.

Lib/typing.py

index 2287f0521a364f13723ee60f8e2f0329931c9627..ca05fb54bf428f28e540cc17e64dc90e43a707a6 100644 (file)
@@ -2512,7 +2512,7 @@ class TextIO(IO[str]):
 
 class _DeprecatedType(type):
     def __getattribute__(cls, name):
-        if name != "__dict__" and name in cls.__dict__:
+        if name not in ("__dict__", "__module__") and name in cls.__dict__:
             warnings.warn(
                 f"{cls.__name__} is deprecated, import directly "
                 f"from typing instead. {cls.__name__} will be removed "