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.

classification
Title: pydoc crashes on a class property
Type: Stage:
Components: Demos and Tools Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: doko, jlgijsbers
Priority: normal Keywords:

Created on 2004-02-06 08:44 by doko, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg19926 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2004-02-06 08:44
[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 
msg19927 - (view) Author: Johannes Gijsbers (jlgijsbers) * (Python triager) Date: 2004-08-08 10:23
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.
msg19928 - (view) Author: Johannes Gijsbers (jlgijsbers) * (Python triager) Date: 2004-08-08 11:31
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.

msg19929 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2004-08-15 17:17
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
msg19930 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2004-08-17 13:26
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
History
Date User Action Args
2022-04-11 14:56:02adminsetgithub: 39906
2004-02-06 08:44:19dokocreate