[Python-Dev] dealing with decorators hiding metadata of decorated functions (original) (raw)

Aahz aahz at pythoncraft.com
Sun Mar 19 22:37:27 CET 2006


On Sun, Mar 19, 2006, Brett Cannon wrote:

I guess we need to decide if we want to promote the copying of metadata from the decorated function into the decorator or not.

Short answer: absolutely yes

I had to deal with a related issue recently, where embedded doctests no longer worked on the decorated function. There were two separate problems: the first was non-copying of doc, which was easy enough to fix; the second (which I still haven't fixed) is the fact that name wasn't set, so doctest didn't auto-find the function. (The decorator came from a different module.)

(This was Python 2.2/2.3, so decorators weren't actually involved, but I think it's the same problem.)

I don't understand decorators well enough to propose a good solution given the other constraints, but it seems clear to me that we need a good solution of some kind.

Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/

"19. A language that doesn't affect the way you think about programming, is not worth knowing." --Alan Perlis



More information about the Python-Dev mailing list