summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichele.simionato <devnull@localhost>2008-12-10 17:11:39 +0000
committermichele.simionato <devnull@localhost>2008-12-10 17:11:39 +0000
commitf1f691a6a455aa49e68f1b55d21d241b848142a4 (patch)
treec1a7832ff9dfdd6cca2e8802b89f2e6be66df413
parentf368a98c18161cc3eb6f316a1e0dd3228a808925 (diff)
downloadpython-decorator-git-f1f691a6a455aa49e68f1b55d21d241b848142a4.tar.gz
Various fixes on the getsource functionality
-rwxr-xr-xdecorator.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/decorator.py b/decorator.py
index a04f9e6..0253ad6 100755
--- a/decorator.py
+++ b/decorator.py
@@ -57,7 +57,7 @@ class FunctionMaker(object):
self.dict = func.__dict__.copy()
if name:
self.name = name
- if signature:
+ if signature is not None:
self.signature = signature
if defaults:
self.defaults = defaults
@@ -67,7 +67,8 @@ class FunctionMaker(object):
self.module = module
if funcdict:
self.dict = funcdict
- self.name, self.signature # check existence required attributes
+ assert self.name and hasattr(self, 'signature')
+ # check existence required attributes
def update(self, func, **kw):
"Update the signature of func with the data in self"
@@ -78,9 +79,9 @@ class FunctionMaker(object):
func.__module__ = getattr(self, 'module', _callermodule())
func.__dict__.update(kw)
- def make(self, templ, save_source=False, **evaldict):
+ def make(self, src_templ, save_source=False, **evaldict):
"Make a new function from a given template and update the signature"
- src = templ % vars(self) # expand name and signature
+ src = src_templ % vars(self) # expand name and signature
mo = DEF.match(src)
if mo is None:
raise SyntaxError('not a valid function template\n%s' % src)