Message100933
As an extra data point: we just hit this problem in Django ticket #13093 (http://code.djangoproject.com/ticket/13093). In our case, a decorator was using wraps(); however, that decorator was breaking when it was used on a class with a __call__ method, because the instance of the class doesn't have a __name__ attribute.
We've implemented the proposed workaround (i.e., check the attributes that are available and provide that tuple as the assigned argument), but I don't agree that this should be expected behavior. wraps() is used to make a decorated callable look like the callable that is being decorated; if there are different types of callable objects, I would personally expect wraps() to adapt to the differences, not raise an error if it sees anything other than a function.
True, some attributes (like __doc__) won't always be correct as a result of wrapping on non-vanilla functions -- but then, that's true of plain vanilla functions, too. A decorator wrapping a function can fundamentally change what the wrapped function does, and there's no guarantee that the docstring for the wrapped function will still be correct after decoration. |
|
Date |
User |
Action |
Args |
2010-03-12 13:00:33 | freakboy3742 | set | recipients:
+ freakboy3742, ncoghlan, pitrou, benjamin.peterson, Antoine d'Otreppe, findepi, brian.curtin, eklitzke |
2010-03-12 13:00:33 | freakboy3742 | set | messageid: <1268398833.51.0.238677747274.issue3445@psf.upfronthosting.co.za> |
2010-03-12 13:00:32 | freakboy3742 | link | issue3445 messages |
2010-03-12 13:00:31 | freakboy3742 | create | |
|