From 10f362eccabc5285f6dce795d256e764906eddea Mon Sep 17 00:00:00 2001 From: Michele Simionato Date: Mon, 2 Nov 2015 06:45:13 +0100 Subject: "f" is no more a special name --- CHANGES.txt | 2 ++ documentation.pdf | 78 +++++++++++++++++++++++++++---------------------------- src/decorator.py | 10 +++---- 3 files changed, 44 insertions(+), 46 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 43cc1b9..80d9a50 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,8 @@ HISTORY -------- +4.0.5 Fixed a bug signaled by David Goldstein: now you can use the name `f` + as a keyword argument of decorated functions (2015/11/02) 4.0.4 Included a patch from Zev Benjamin: now decorated functions play well with cProfile (2015/09/25) 4.0.3 Added a warning about the memoize example, as requested by Robert diff --git a/documentation.pdf b/documentation.pdf index d41bc04..fd83a7c 100644 --- a/documentation.pdf +++ b/documentation.pdf @@ -269,7 +269,7 @@ endobj << /Outlines 83 0 R /PageLabels 125 0 R /PageMode /UseNone /Pages 103 0 R /Type /Catalog >> endobj 82 0 obj -<< /Author (Michele Simionato) /CreationDate (D:20150925043543-01'00') /Creator (\(unspecified\)) /Keywords () /Producer (ReportLab PDF Library - www.reportlab.com) /Subject (\(unspecified\)) +<< /Author (Michele Simionato) /CreationDate (D:20151102064211-01'00') /Creator (\(unspecified\)) /Keywords () /Producer (ReportLab PDF Library - www.reportlab.com) /Subject (\(unspecified\)) /Title (The decorator module) >> endobj 83 0 obj @@ -403,7 +403,7 @@ q 1 0 0 1 91.03937 3 cm q 0 0 0 rg -BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (4.0.4 \(2015-09-25\)) Tj T* ET +BT 1 0 0 1 0 2 Tm /F1 10 Tf 12 TL (4.0.4 \(2015-11-02\)) Tj T* ET Q Q q @@ -4373,7 +4373,7 @@ Q endstream endobj 113 0 obj -<< /Length 14062 >> +<< /Length 14063 >> stream 1 0 0 1 0 0 cm BT /F1 12 Tf 14.4 TL ET q @@ -4461,7 +4461,7 @@ Q q 1 0 0 1 62.69291 374.8236 cm q -BT 1 0 0 1 0 26 Tm .414597 Tw 12 TL /F3 10 Tf 0 0 0 rg (FunctionMaker ) Tj /F1 10 Tf 0 0 0 rg (provides a ) Tj /F3 10 Tf 0 0 0 rg (.create ) Tj /F1 10 Tf 0 0 0 rg (classmethod which takes as input the name, signature, and body) Tj T* 0 Tw .632927 Tw (of the function we want to generate as well as the execution environment were the function is generated) Tj T* 0 Tw (by ) Tj /F3 10 Tf 0 0 0 rg (exec) Tj /F1 10 Tf 0 0 0 rg (. Here is an example:) Tj T* ET +BT 1 0 0 1 0 26 Tm .414597 Tw 12 TL /F3 10 Tf 0 0 0 rg (FunctionMaker ) Tj /F1 10 Tf 0 0 0 rg (provides a ) Tj /F3 10 Tf 0 0 0 rg (.create ) Tj /F1 10 Tf 0 0 0 rg (classmethod which takes as input the name, signature, and body) Tj T* 0 Tw .305868 Tw (of the function we want to generate as well as the execution environment where the function is generated) Tj T* 0 Tw (by ) Tj /F3 10 Tf 0 0 0 rg (exec) Tj /F1 10 Tf 0 0 0 rg (. Here is an example:) Tj T* ET Q Q q @@ -8869,44 +8869,44 @@ xref 0000115828 00000 n 0000134508 00000 n 0000152994 00000 n -0000167115 00000 n -0000185278 00000 n -0000199751 00000 n -0000213917 00000 n -0000229201 00000 n -0000245964 00000 n -0000257749 00000 n -0000271179 00000 n -0000285542 00000 n -0000295235 00000 n -0000308459 00000 n -0000309961 00000 n -0000310234 00000 n -0000310272 00000 n -0000310310 00000 n -0000310348 00000 n -0000310386 00000 n -0000310424 00000 n -0000310462 00000 n -0000310500 00000 n -0000310538 00000 n -0000310576 00000 n -0000310615 00000 n -0000310654 00000 n -0000310693 00000 n -0000310732 00000 n -0000310771 00000 n -0000310810 00000 n -0000310849 00000 n -0000310888 00000 n -0000310927 00000 n -0000310966 00000 n -0000311005 00000 n +0000167116 00000 n +0000185279 00000 n +0000199752 00000 n +0000213918 00000 n +0000229202 00000 n +0000245965 00000 n +0000257750 00000 n +0000271180 00000 n +0000285543 00000 n +0000295236 00000 n +0000308460 00000 n +0000309962 00000 n +0000310235 00000 n +0000310273 00000 n +0000310311 00000 n +0000310349 00000 n +0000310387 00000 n +0000310425 00000 n +0000310463 00000 n +0000310501 00000 n +0000310539 00000 n +0000310577 00000 n +0000310616 00000 n +0000310655 00000 n +0000310694 00000 n +0000310733 00000 n +0000310772 00000 n +0000310811 00000 n +0000310850 00000 n +0000310889 00000 n +0000310928 00000 n +0000310967 00000 n +0000311006 00000 n trailer << /ID % ReportLab generated PDF document -- digest (http://www.reportlab.com) - [(\227\221@\343e\271\027\027\375q\340'\256\220`\354) (\227\221@\343e\271\027\027\375q\340'\256\220`\354)] + [(\035\333\023*u,=s\221B\177\325\202\003\276\277) (\035\333\023*u,=s\221B\177\325\202\003\276\277)] /Info 82 0 R /Root 81 0 R /Size 147 >> startxref -311044 +311045 %%EOF diff --git a/src/decorator.py b/src/decorator.py index 13aeef4..16b061c 100644 --- a/src/decorator.py +++ b/src/decorator.py @@ -33,8 +33,6 @@ for the documentation. """ from __future__ import print_function -__version__ = '4.0.4' - import re import sys import inspect @@ -42,6 +40,8 @@ import operator import itertools import collections +__version__ = '4.0.5' + if sys.version >= '3': from inspect import getfullargspec @@ -247,7 +247,6 @@ def decorator(caller, _func=None): callerfunc = get_init(caller) doc = 'decorator(%s) converts functions/generators into ' \ 'factories of %s objects' % (caller.__name__, caller.__name__) - fun = getfullargspec(callerfunc).args[1] # second arg elif inspect.isfunction(caller): if caller.__name__ == '': name = '_lambda_' @@ -255,18 +254,15 @@ def decorator(caller, _func=None): name = caller.__name__ callerfunc = caller doc = caller.__doc__ - fun = getfullargspec(callerfunc).args[0] # first arg else: # assume caller is an object with a __call__ method name = caller.__class__.__name__.lower() callerfunc = caller.__call__.__func__ doc = caller.__call__.__doc__ - fun = getfullargspec(callerfunc).args[1] # second arg evaldict = callerfunc.__globals__.copy() evaldict['_call_'] = caller evaldict['_decorate_'] = decorate return FunctionMaker.create( - '%s(%s)' % (name, fun), - 'return _decorate_(%s, _call_)' % fun, + '%s(_f_)' % name, 'return _decorate_(_f_, _call_)', evaldict, doc=doc, module=caller.__module__, __wrapped__=caller) -- cgit v1.2.1