]> granicus.if.org Git - python/commitdiff
Issue #11666: Teach pydoc to display full help for named tuples
authorRaymond Hettinger <python@rcn.com>
Fri, 25 Mar 2011 21:16:13 +0000 (14:16 -0700)
committerRaymond Hettinger <python@rcn.com>
Fri, 25 Mar 2011 21:16:13 +0000 (14:16 -0700)
1  2 
Lib/pydoc.py
Lib/test/test_pydoc.py
Misc/NEWS

diff --cc Lib/pydoc.py
index 9f8f120c94835a6e6865aa1ada6dc5d71e62f52f,dc398e3beaa7a4c299bcb750480248b721802bcf..739b440696a456490dc638021a7095bf3a22c814
@@@ -165,16 -165,19 +165,19 @@@ def _split_list(s, predicate)
              no.append(x)
      return yes, no
  
- def visiblename(name, all=None):
+ def visiblename(name, all=None, obj=None):
      """Decide whether to show documentation on a variable."""
      # Certain special names are redundant.
 -    _hidden_names = ('__builtins__', '__doc__', '__file__', '__path__',
 +    if name in {'__builtins__', '__doc__', '__file__', '__path__',
                       '__module__', '__name__', '__slots__', '__package__',
                       '__cached__', '__author__', '__credits__', '__date__',
 -                     '__version__')
 -    if name in _hidden_names: return 0
 +                     '__version__'}:
 +        return 0
      # Private names are hidden, but special names are displayed.
      if name.startswith('__') and name.endswith('__'): return 1
+     # Namedtuples have public fields and methods with a single leading underscore
+     if name.startswith('_') and hasattr(obj, '_fields'):
+         return True
      if all is not None:
          # only document that which the programmer exported in __all__
          return name in all
Simple merge
diff --cc Misc/NEWS
index f70998c9db7fa51019fc54928cf8d6f550ea6bec,7a73054b5ae84a643ec018a573fc11049dfe5f8b..f60f79b51c445522bfc714aaf930b42179830f45
+++ b/Misc/NEWS
@@@ -84,27 -49,11 +84,30 @@@ Core and Builtin
  Library
  -------
  
 -- Issue #11628: cmp_to_key generated class should use __slots__
 +- Issue #6811: Allow importlib to change a code object's co_filename attribute
 +  to match the path to where the source code currently is, not where the code
 +  object originally came from.
 +
 +- Issue #8754: Have importlib use the repr of a module name in error messages.
 +
 +- Issue #11591: Prevent "import site" from modifying sys.path when python
 +  was started with -S.
 +
 +- collections.namedtuple() now adds a _source attribute to the generated
 +  class.  This make the source more accessible than the outdated
 +  "verbose" option which prints to stdout but doesn't make the source
 +  string available.
 +
 +- Issue #11371: Mark getopt error messages as localizable.  Patch by Filip
 +  GruszczyƄski.
 +
 +- Issue #11333: Add __slots__ to collections ABCs.
 +
 +- Issue #11628: cmp_to_key generated class should use __slots__.
  
+ - Issue #11666: let help() display named tuple attributes and methods
+   that start with a leading underscore.
  - Issue #5537: Fix time2isoz() and time2netscape() functions of
    httplib.cookiejar for expiration year greater than 2038 on 32-bit systems.