cpython: b2ee3fe195e2 (original) (raw)

Mercurial > cpython

changeset 89759:b2ee3fe195e2 3.4

Issue #20710: The pydoc summary line no longer displays the "self" parameter for bound methods. Previous to this change, it displayed "self" for methods implemented in Python but not methods implemented in C; it is now both internally consistent and consistent with inspect.Signature. [#20710]

Larry Hastings larry@hastings.org
date Thu, 20 Feb 2014 23:34:46 -0800
parents ed1059f5507b
children 1597d5e3cf2e
files Lib/pydoc.py Lib/test/test_pydoc.py Misc/NEWS
diffstat 3 files changed, 54 insertions(+), 10 deletions(-)[+] [-] Lib/pydoc.py 21 Lib/test/test_pydoc.py 40 Misc/NEWS 3

line wrap: on

line diff

--- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -137,6 +137,19 @@ def _is_some_method(obj): inspect.isbuiltin(obj) or inspect.ismethoddescriptor(obj)) +def _is_bound_method(fn):

+ + def allmethods(cl): methods = {} for key, value in inspect.getmembers(cl, _is_some_method): @@ -898,7 +911,7 @@ class HTMLDoc(Doc): anchor = (cl and cl.name or '') + '-' + name note = '' skipdocs = 0

@@ -909,7 +922,6 @@ class HTMLDoc(Doc): object.self.class, mod) else: note = ' unbound %s method' % self.classlink(imclass,mod)

if name == realname: title = '%s' % (anchor, realname) @@ -924,7 +936,7 @@ class HTMLDoc(Doc): title = '%s = %s' % ( anchor, name, reallink) argspec = None

@@ -1301,7 +1313,7 @@ location listed above. name = name or realname note = '' skipdocs = 0

@@ -1312,7 +1324,6 @@ location listed above. object.self.class, mod) else: note = ' unbound %s method' % classname(imclass,mod)

if name == realname: title = self.bold(realname)

--- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -6,6 +6,7 @@ import difflib import inspect import pydoc import keyword +import _pickle import pkgutil import re import string @@ -689,12 +690,41 @@ class TestDescriptions(unittest.TestCase self.assertIsNone(pydoc.locate(name)) self.assertRaises(ImportError, pydoc.render_doc, name)

+

+ @requires_docstrings

+

+

+

@unittest.skipUnless(threading, 'Threading required for this test.')

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -26,6 +26,9 @@ Core and Builtins Library ------- +- Issue #20710: The pydoc summary line no longer displays the "self" parameter