bpo-34966: Improve support of method aliases in pydoc. (GH-9823)


Pydoc now does not duplicate docstrings for aliases of inherited methods.
(cherry picked from commit a44d34e17908a49d584f86c4f8642a50707b7150)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 8a6b27b..09992cd 100644
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -958,8 +958,7 @@
         if name == realname:
             title = '<a name="%s"><strong>%s</strong></a>' % (anchor, realname)
         else:
-            if (cl and realname in cl.__dict__ and
-                cl.__dict__[realname] is object):
+            if cl and inspect.getattr_static(cl, realname, []) is object:
                 reallink = '<a href="#%s">%s</a>' % (
                     cl.__name__ + '-' + realname, realname)
                 skipdocs = 1
@@ -1375,8 +1374,7 @@
         if name == realname:
             title = self.bold(realname)
         else:
-            if (cl and realname in cl.__dict__ and
-                cl.__dict__[realname] is object):
+            if cl and inspect.getattr_static(cl, realname, []) is object:
                 skipdocs = 1
             title = self.bold(name) + ' = ' + realname
         argspec = None