From e298f33d7ee4580fefccb491018a8417e4319236 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Tue, 21 Oct 2003 20:59:51 +0000 Subject: [PATCH] Fixed problem with new.function. --- plugins/Alias.py | 3 +-- src/privmsgs.py | 15 ++++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/plugins/Alias.py b/plugins/Alias.py index d23b44b32..6754ead4f 100644 --- a/plugins/Alias.py +++ b/plugins/Alias.py @@ -148,10 +148,9 @@ def makeNewAlias(name, alias): alias_ = atRe.sub(replace, alias_) alias_ = alias_.replace('$*', ' '.join(map(utils.dqrepr, args))) self.Proxy(irc.irc, msg, callbacks.tokenize(alias_)) - #f = new.function(f.func_code, f.func_globals, alias) + f = new.function(f.func_code, f.func_globals, name, closure=f.func_closure) f.__doc__ ='\n\nAlias for %r' % \ (utils.nItems(biggestDollar, 'argument'), alias) - #f = new.function(f.func_code, f.func_globals, name) return f diff --git a/src/privmsgs.py b/src/privmsgs.py index 00661bcd5..93b50068a 100644 --- a/src/privmsgs.py +++ b/src/privmsgs.py @@ -84,7 +84,8 @@ def checkCapability(f, capability): f(self, irc, msg, args) else: irc.error(msg, conf.replyNoCapability % capability) - #newf = new.function(newf.func_code, newf.func_globals, f.func_name) + newf = new.function(newf.func_code, newf.func_globals, + f.func_name, closure=newf.func_closure) newf.__doc__ = f.__doc__ return newf @@ -102,7 +103,8 @@ def checkChannelCapability(f, capability): ff(irc, msg, args, *L) else: irc.error(msg, conf.replyNoCapability % chancap) - #newf = new.function(newf.func_code, newf.func_globals, f.func_name) + newf = new.function(newf.func_code, newf.func_globals, + f.func_name, closure=newf.func_closure) newf.__doc__ = f.__doc__ return newf @@ -112,7 +114,8 @@ def thread(f): ff = new.instancemethod(f, self, self.__class__) t = callbacks.CommandThread(self.callCommand, ff, irc, msg, args, *L) t.start() - #newf = new.function(newf.func_code, newf.func_globals, f.func_name) + newf = new.function(newf.func_code, newf.func_globals, + f.func_name, closure=newf.func_closure) newf.__doc__ = f.__doc__ return newf @@ -130,7 +133,8 @@ def name(f): L = (name,) + L ff = new.instancemethod(f, self, self.__class__) ff(irc, msg, args, *L) - #newf = new.function(newf.func_code, newf.func_globals, f.func_name) + newf = new.function(newf.func_code, newf.func_globals, + f.func_name, closure=newf.func_closure) newf.__doc__ = f.__doc__ return newf @@ -141,7 +145,8 @@ def channel(f): L = (channel,) + L ff = new.instancemethod(f, self, self.__class__) ff(irc, msg, args, *L) - #newf = new.function(newf.func_code, newf.func_globals, f.func_name) + newf = new.function(newf.func_code, newf.func_globals, + f.func_name, closure=newf.func_closure) newf.__doc__ = f.__doc__ return newf