Issue530070
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2002-03-14 22:35 by tim.peters, last changed 2022-04-10 16:05 by admin. This issue is now closed.
Files | ||||
---|---|---|---|---|
File name | Uploaded | Description | Edit | |
type.txt | loewis, 2002-03-15 09:57 | |||
type2.txt | gvanrossum, 2002-03-15 15:07 | Improved patch, uses HEAPTYPE flag | ||
inspect.txt | loewis, 2002-03-15 17:39 | |||
inspect2.txt | gvanrossum, 2002-03-15 18:27 | |||
inspect3.txt | gvanrossum, 2002-03-15 18:55 | cosmetic fix for inspect2.txt |
Messages (14) | |||
---|---|---|---|
msg9707 - (view) | Author: Tim Peters (tim.peters) * | Date: 2002-03-14 22:35 | |
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. |
|||
msg9708 - (view) | Author: A.M. Kuchling (akuchling) * | Date: 2002-03-15 00:13 | |
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? |
|||
msg9709 - (view) | Author: Tim Peters (tim.peters) * | Date: 2002-03-15 00:48 | |
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. |
|||
msg9710 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2002-03-15 09:57 | |
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. |
|||
msg9711 - (view) | Author: Guido van Rossum (gvanrossum) * | Date: 2002-03-15 15:07 | |
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. |
|||
msg9712 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2002-03-15 17:39 | |
Logged In: YES user_id=21627 I recommend to guarantee that inspect.getdoc always returns a string or None. The attached patch should cover all cases discussed so far: if __doc__ is a non-string object, it will produce a string version of it - somewhat ugly, but not catastrophic. If it is a Unicode object, it will return nothing if that does not convert into a byte string. Together with Guido's patch, this should bring us back to the 2.2 state. |
|||
msg9713 - (view) | Author: Tim Peters (tim.peters) * | Date: 2002-03-15 18:14 | |
Logged In: YES user_id=31435 Thanks, fellows! Let's leave this assigned to me. I'll get to it over the weekend (if not toady). |
|||
msg9714 - (view) | Author: Guido van Rossum (gvanrossum) * | Date: 2002-03-15 18:27 | |
Logged In: YES user_id=6380 I've appended a better version (IMO) of the inspect patch. I find it ugly to have to catch UnicodeError with a comment explaining it. My version (inspect2.txt) leaves nothing to the imagination. It also makes sure that there's an explicit return in each path through the function. Random gripe: why doesn't inspect.py use string methods? The string module looks soooooooo dorky... |
|||
msg9715 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2002-03-15 18:42 | |
Logged In: YES user_id=21627 Your inspect patch has undesirable results. Given class Foo: u"Autor: v. Löwis" help(Foo) will produce a UnicodeError. This is undesirable, IMO - it should better just ignore the doc string. It may be sensible to ignore this for now, hoping that output devices which support full Unicode become available (actually, the pydoc web server, can, in principle, support this case well). |
|||
msg9716 - (view) | Author: Guido van Rossum (gvanrossum) * | Date: 2002-03-15 18:55 | |
Logged In: YES user_id=6380 Indeed, but that's a different problem worthy of a separate bug report. It happens in the unpatched code too, so I don't think it is a result of my patch -- it just so happens that your patch also addressed this. But I believe getdoc() should work for Unicode strings just fine. I've uploaded inspect3.txt which addresses a different cosmetic issue but is otherwise the same as inspect2.txt. |
|||
msg9717 - (view) | Author: Tim Peters (tim.peters) * | Date: 2002-03-17 19:00 | |
Logged In: YES user_id=31435 I applied type2.txt and inspect3.txt to the trunk and to release22-maint. If you believe there are other bugs here that need fixing day, please open new bug reports. Lib/inspect.py new revision: 1.28 new revision: 1.26.10.2 Objects/typeobject.c new revision: 2.130 new revision: 2.126.4.4 |
|||
msg9718 - (view) | Author: James Henstridge (jamesh) | Date: 2002-04-12 11:30 | |
Logged In: YES user_id=146903 Please reconsider this patch. My patch in bug #504343 was designed to let me use a descriptor for the __doc__ attribute of some of my classes in PyGTK. I add some information in the docstrings is looked up via introspection (so that it is in sync with the objects I am wrapping, and also to avoid the startup overhead), which is why I wanted to use a descriptor. Your patch means that all classes (which are non heap type) now return None when instead of calling the descriptor. For heap type classes, it won't call the descriptor's tp_descr_get() method if __doc__ happens to be a descriptor -- instead returning the descriptor itself. Would it be possible to reconsider this fix? If not for 2.2.1, at least for 2.3. Maybe just adding an extra str() call in pydoc/inspect would fix the problem. Being able to use descriptors for the __doc__ attribute in order to load docs lazily may be useful for other purposes as well (not just pygtk). Would it be better open a new bug for this, or reopen this report? |
|||
msg9719 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2002-04-12 12:27 | |
Logged In: YES user_id=21627 James, it would be better to submit a new bug report for this. I have problems figuring out what it is that you want to do, so please include a small example, saying what it is that you expect to happen, and what happens instead. |
|||
msg9720 - (view) | Author: James Henstridge (jamesh) | Date: 2002-04-12 13:24 | |
Logged In: YES user_id=146903 I have openeed bug #542984 to track this issue. Please add yourself to the CC list if you are interested. I will attach a patch for inspect.py to that bug that solves the above pydoc error shortly. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:05:06 | admin | set | github: 36260 |
2002-03-14 22:35:45 | tim.peters | create |