Decorator cllass hides docstring from doctest?

Berthold Höllmann berthold at
Thu Sep 21 14:57:43 CEST 2006

Saving the following code to a file and running the code through
python does not give the expected error. disableling the "@decor" line
leads to the expected error message. Is this a bug or an overseen

--- snip ---
class decor(object):
    def __init__(self, f):
        self.f = f
    def __call__(self, *args, **kw):
        return self.f(*args, **kw)

def f(a, b):
    >>> f(1,2)
    >>> f(2,2)
    return a == b

def _test():
    import doctest

if __name__ == "__main__":
--- snip ---

Our Python is:

Python 2.4.2 (#1, Dec  5 2005, 10:13:23) 
[GCC 3.3.5 20050117 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

                            __   Address:
                         G /  \ L Germanischer Lloyd
phone: +49-40-36149-7374 -+----+- Vorsetzen 35       P.O.Box 111606
fax  : +49-40-36149-7320   \__/   D-20459 Hamburg    D-20416 Hamburg

More information about the Python-list mailing list