diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-10-18 19:56:17 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-10-18 19:56:17 (GMT) |
commit | 8dd7adeb34cdbbb7b3b95ab502699d08b7ba328c (patch) | |
tree | a77d551a385ea6301ef5d9fd8dd4bbfcc37bd2eb /Lib/test/pydocfodder.py | |
parent | a6535fd40b7220350d007b1dcab3fbccaa6a3092 (diff) | |
download | cpython-8dd7adeb34cdbbb7b3b95ab502699d08b7ba328c.zip cpython-8dd7adeb34cdbbb7b3b95ab502699d08b7ba328c.tar.gz cpython-8dd7adeb34cdbbb7b3b95ab502699d08b7ba328c.tar.bz2 |
SF bug [#472347] pydoc and properties.
The GUI-mode code to display properties blew up if the property functions
(get, set, etc) weren't simply methods (or functions).
"The problem" here is really that the generic document() method dispatches
to one of .doc{routine, class, module, other}(), but all of those require
a different(!) number of arguments. Thus document isn't general-purpose
at all: you have to know exactly what kind of thing is it you're going
to document first, in order to pass the correct number of arguments to
.document for it to pass on. As an expedient hack, just tacked "*ignored"
on to the end of the formal argument lists for the .docXXX routines so
that .document's caller doesn't have to know in advance which path
.document is going to take.
Diffstat (limited to 'Lib/test/pydocfodder.py')
-rw-r--r-- | Lib/test/pydocfodder.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/pydocfodder.py b/Lib/test/pydocfodder.py index 7ccac5e..becdf22 100644 --- a/Lib/test/pydocfodder.py +++ b/Lib/test/pydocfodder.py @@ -177,3 +177,34 @@ class D_new(B_new, C_new): "Method defined in C and D." def D_method(self): "Method defined in D." + +class FunkyProperties(object): + """From SF bug 472347, by Roeland Rengelink. + + Property getters etc may not be vanilla functions or methods, + and this used to make GUI pydoc blow up. + """ + + def __init__(self): + self.desc = {'x':0} + + class get_desc: + def __init__(self, attr): + self.attr = attr + def __call__(self, inst): + print 'Get called', self, inst + return inst.desc[self.attr] + class set_desc: + def __init__(self, attr): + self.attr = attr + def __call__(self, inst, val): + print 'Set called', self, inst, val + inst.desc[self.attr] = val + class del_desc: + def __init__(self, attr): + self.attr = attr + def __call__(self, inst): + print 'Del called', self, inst + del inst.desc[self.attr] + + x = property(get_desc('x'), set_desc('x'), del_desc('x'), 'prop x') |