[ python-Bugs-891637 ] pydoc crashes on a class property
SourceForge.net
noreply at sourceforge.net
Sun Aug 15 19:17:26 CEST 2004
Bugs item #891637, was opened at 2004-02-06 09:44
Message generated for change (Comment added) made by doko
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=891637&group_id=5470
Category: Demos and Tools
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Matthias Klose (doko)
Assigned to: Nobody/Anonymous (nobody)
Summary: pydoc crashes on a class property
Initial Comment:
[forwarded from http://bugs.debian.org/231202]
---
class foo(object):
__slots__ = ['_bar']
bar = property(lambda (self): self._bar)
def __init__(self, bar): self._bar = bar
f = foo(1)
assert(f.bar == 1)
---
removing the parenthesis around the lambda's parameter
avoids the pydoc crash. Python itself doesn't seem to
care about the parenthesis.
$ python tmp.py # no errors
$ pydoc tmp
Traceback (most recent call last):
File "/usr/bin/pydoc", line 4, in ?
pydoc.cli()
File "/usr/lib/python2.3/pydoc.py", line 2123, in cli
help.help(arg)
File "/usr/lib/python2.3/pydoc.py", line 1582, in help
elif request: doc(request, 'Help on %s:')
File "/usr/lib/python2.3/pydoc.py", line 1375, in doc
pager(title % desc + '\n\n' + text.document(object,
name))
File "/usr/lib/python2.3/pydoc.py", line 283, in
document
if inspect.ismodule(object): return
self.docmodule(*args)
File "/usr/lib/python2.3/pydoc.py", line 990, in
docmodule
contents.append(self.document(value, key, name))
File "/usr/lib/python2.3/pydoc.py", line 284, in
document
if inspect.isclass(object): return
self.docclass(*args)
File "/usr/lib/python2.3/pydoc.py", line 1135, in
docclass
lambda t: t[1] == 'property')
File "/usr/lib/python2.3/pydoc.py", line 1087, in
spillproperties
base = self.document(func, tag, mod)
File "/usr/lib/python2.3/pydoc.py", line 285, in
document
if inspect.isroutine(object): return
self.docroutine(*args)
File "/usr/lib/python2.3/pydoc.py", line 1177, in
docroutine
args, varargs, varkw, defaults =
inspect.getargspec(object)
File "/usr/lib/python2.3/inspect.py", line 656, in
getargspec
args, varargs, varkw = getargs(func.func_code)
File "/usr/lib/python2.3/inspect.py", line 624, in
getargs
remain[-1] = remain[-1] - 1
IndexError: list index out of range
----------------------------------------------------------------------
>Comment By: Matthias Klose (doko)
Date: 2004-08-15 19:17
Message:
Logged In: YES
user_id=60903
Fixed in
- Lib/inspect.py 1.53 and 1.47.8.2
- Lib/test/test_inspect.py 1.15 and 1.12.8.3
----------------------------------------------------------------------
Comment By: Johannes Gijsbers (jlgijsbers)
Date: 2004-08-08 13:31
Message:
Logged In: YES
user_id=469548
This crashes as well:
def foo((bar)): return 1
A patch is available at http://python.org/sf/1005466.
----------------------------------------------------------------------
Comment By: Johannes Gijsbers (jlgijsbers)
Date: 2004-08-08 12:23
Message:
Logged In: YES
user_id=469548
First, note that the problem doesn't lie in properties. This
crashes as well:
foo = lambda (bar): 1
second, Python does care about the parentheses. It just
doesn't matter when the lambda has only one argument. Using
parentheses creates a sublist instead of a parameter list,
as in the following example with normal functions:
def foo((bar, baz)): return bar
assert(foo((1, 2)) == 1)
pydoc (or rather, inspect) should still be fixed though.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=891637&group_id=5470
More information about the Python-bugs-list
mailing list