Closed benoitbryon closed 9 years ago
Hum, I think I will restore the former behaviour and focus on fixing the doctests here... So the behaviour changes are not part of this deal...
Ahaha, functools.WRAPPER_ASSIGNMENTS
is not the same in Python2 and Python3... Let's restore ('__name__', '__doc__')
and try functools later, in another PR.
Done, doctests pass, with minimal changes of behaviour.
I had to change the README, because print(my_function.__name__)
actually outputs None
when the name is None
.
https://travis-ci.org/zeekay/decorum/jobs/73708648#L165-L171 Looks like it would also fix #8.
Cool!
This pull-requests is based on https://github.com/zeekay/decorum/pull/15. In https://github.com/zeekay/decorum/pull/15, "build fails if doctests fail", but doctests actually fail. Here, I added a fix for the doctests, but I'm not sure about the implementation. So you may accept one pull-request but not the other...
Here, I did a change in the behaviour of the
assigned
feature. Check changes in README:assigned
is nowfunctools.WRAPPER_ASSIGNMENTS
, see https://docs.python.org/2.7/library/functools.html#functools.update_wrapper. It adds__module__
to the default value. I think it is good to be consistent with Python's standard library. That said, I can restore the former default if you like, and create a new pull-request/discussion for this change. Just tell me ;)assigned
is None, then__name__
and__doc__
of the decorated object are the ones of the decorator class, i.e.identity
andNoop decorator: does nothing!
instead ofNone
andNone
. I think it is more consistent... That said, again, I can restore the former behaviour, and perhaps ask for this change in a new pull-request/discussion. Just tell me ;)What's important here is that doctests are fixed!