[Python-bugs-list] [ python-Bugs-530070 ] pydoc regression

noreply@sourceforge.net noreply@sourceforge.net
Fri, 15 Mar 2002 07:07:55 -0800


Bugs item #530070, was opened at 2002-03-14 17:35
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=530070&group_id=5470

Category: Python Library
Group: Python 2.2.1 candidate
Status: Open
Resolution: None
Priority: 7
Submitted By: Tim Peters (tim_one)
Assigned to: Tim Peters (tim_one)
Summary: pydoc regression

Initial Comment:
In current CVS trunk and release22-maint branch:

C:\Pyt>python
Python 2.2.1a1 (#32, Mar 14 2002, 14:10:11) [MSC 32 
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for 
more information.
>>> import __builtin__
>>> help(__builtin__)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "C:\Pyt\lib\site.py", line 279, in __call__
    return pydoc.help(*args, **kwds)
  File "C:\Pyt\lib\pydoc.py", line 1509, in __call__
    self.help(request)
  File "C:\Pyt\lib\pydoc.py", line 1545, in help
    else: doc(request, 'Help on %s:')
  File "C:\Pyt\lib\pydoc.py", line 1340, in doc
    pager(title % (desc + suffix) + '\n\n' + 
text.document(thing, name))
  File "C:\Pyt\lib\pydoc.py", line 267, in document
    if inspect.ismodule(object): return apply
(self.docmodule, args)
  File "C:\Pyt\lib\pydoc.py", line 960, in docmodule
    contents.append(self.document(value, key, name))
  File "C:\Pyt\lib\pydoc.py", line 268, in document
    if inspect.isclass(object): return apply
(self.docclass, args)
  File "C:\Pyt\lib\pydoc.py", line 1005, in docclass
    doc = getdoc(object)
  File "C:\Pyt\lib\pydoc.py", line 66, in getdoc
    result = inspect.getdoc(object) or 
inspect.getcomments(object)
  File "C:\Pyt\lib\inspect.py", line 267, in getdoc
    lines = string.split(string.expandtabs
(object.__doc__), '\n')
  File "C:\Pyt\lib\string.py", line 298, in expandtabs
    return s.expandtabs(tabsize)
AttributeError: 'member_descriptor' object has no 
attribute 'expandtabs'
>>>

help(__builtin__) worked in 2.2.  Trying to browse the 
__builtin__ module from GUI pydoc crashes pydoc for 
the same reason.

----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-03-15 10:07

Message:
Logged In: YES 
user_id=6380

Hm, that doesn't solve all cases. E.g.
types.FunctionType.__doc__ is None in 2.2, but returns a
descriptor in current CVS, and still after your patch.

I've attached a new patch that looks at the HEAPTYPE flag.
When the HEAPTYPE flag is clear, it's a type defined in C,
and we should believe tp_doc. When HEAPTYPE is set, it's a
new-style class defined in Python, and we should believe
__dict__['__doc__'].

But pydoc is still broken, and needs to be fixed, because
one could define a type in Python that has a __doc__
descriptor for its instances, and then pydoc would still do
the wrong thing.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-03-15 04:57

Message:
Logged In: YES 
user_id=21627

This was changed with typeobject.c 2.127, which changed
__doc__ access to always look into the __dict__ and never
into  tp_doc, to allow for Unicode doc strings.

The attached patch partially reverts this change: it now
duplicates tp_doc if present, and only returns
__dict__['__doc__'] if tp_doc is NULL.

----------------------------------------------------------------------

Comment By: Tim Peters (tim_one)
Date: 2002-03-14 19:48

Message:
Logged In: YES 
user_id=31435

Well, it's obviously not expected by pydoc <wink>.  In 2.2, 
__builtin__.property.__doc__ was a string.  I've no idea 
why it changed, but it doesn't smell right to me.  Maybe 
Guido knows?  Assigning to him just in case.

----------------------------------------------------------------------

Comment By: A.M. Kuchling (akuchling)
Date: 2002-03-14 19:13

Message:
Logged In: YES 
user_id=11375

The fundamental problem is that __builtin__.property.__doc__ 

returns an object of type 'member_descriptor', not a string.
Is that 
expected?


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=530070&group_id=5470