From 651bc5b6e0b820d77048598fea50180d8613aa72 Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Thu, 1 Sep 2011 11:40:06 +0200 Subject: Fixed a bug with __kwdefaults__ for Python 3 --- decorator/CHANGES.txt | 2 ++ decorator/documentation3.py | 9 +++++++++ decorator/src/decorator.py | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/decorator/CHANGES.txt b/decorator/CHANGES.txt index ea4fd30..cbc1913 100644 --- a/decorator/CHANGES.txt +++ b/decorator/CHANGES.txt @@ -1,6 +1,8 @@ HISTORY ---------- +3.3.2 Fixed a bug with __kwdefaults__ for Python 3, submitted by Chris + Ellison (01/09/2011) 3.3.1 Fixed a doctest broken for Python 3.2, as noted by Arfrever Frehtes Taifersar Arahesis; changed the name of the attribute ``undecorated`` to ``__wrapped__`` following the diff --git a/decorator/documentation3.py b/decorator/documentation3.py index a154f30..47d9c80 100644 --- a/decorator/documentation3.py +++ b/decorator/documentation3.py @@ -1054,5 +1054,14 @@ def a_test_for_pylons(): 'The good old factorial' """ +def test_kwonlydefaults(): + """ + >>> @trace + ... def f(arg, defarg=1, *args, kwonly=2): pass + ... + >>> f.__kwdefaults__ + {'kwonly': 2} + """ + if __name__ == '__main__': import doctest; doctest.testmod() diff --git a/decorator/src/decorator.py b/decorator/src/decorator.py index 67e2221..5daf10b 100644 --- a/decorator/src/decorator.py +++ b/decorator/src/decorator.py @@ -28,7 +28,7 @@ Decorator module, see http://pypi.python.org/pypi/decorator for the documentation. """ -__version__ = '3.3.1' +__version__ = '3.3.2' __all__ = ["decorator", "FunctionMaker", "partial"] @@ -127,6 +127,7 @@ class FunctionMaker(object): func.__doc__ = getattr(self, 'doc', None) func.__dict__ = getattr(self, 'dict', {}) func.func_defaults = getattr(self, 'defaults', ()) + func.__kwdefaults__ = getattr(self, 'kwonlydefaults', None) callermodule = sys._getframe(3).f_globals.get('__name__', '?') func.__module__ = getattr(self, 'module', callermodule) func.__dict__.update(kw) -- cgit v1.2.1