diff --git a/plugins/Alias.py b/plugins/Alias.py index df06460a3..62eea9322 100644 --- a/plugins/Alias.py +++ b/plugins/Alias.py @@ -40,7 +40,6 @@ import plugins import os import re import sets -import types import conf import utils @@ -148,10 +147,9 @@ def makeNewAlias(name, alias): Owner = irc.getCallback('Owner') Owner.disambiguate(irc, tokens) self.Proxy(irc.irc, msg, tokens) - f = types.FunctionType(f.func_code, f.func_globals, - name, closure=f.func_closure) - f.__doc__ ='\n\nAlias for %r' % \ - (utils.nItems('argument', biggestDollar), alias) + doc ='\n\nAlias for %r' % \ + (utils.nItems('argument', biggestDollar), alias) + f = utils.changeFunctionName(f, name, doc) return f diff --git a/plugins/Lookup.py b/plugins/Lookup.py index a72dd0293..4cb70aff5 100644 --- a/plugins/Lookup.py +++ b/plugins/Lookup.py @@ -41,7 +41,6 @@ import os import re import sys import sets -import types import getopt import string @@ -183,8 +182,6 @@ class Lookup(callbacks.Privmsg): def f(self, irc, msg, args): args.insert(0, name) self._lookup(irc, msg, args) - f = types.FunctionType(f.func_code, f.func_globals, - name, closure=f.func_closure) db = self.dbHandler.getDb() cursor = db.cursor() cursor.execute("""SELECT COUNT(*) FROM %s""" % name) @@ -195,9 +192,7 @@ class Lookup(callbacks.Privmsg): returns a random key: value pair from the database. There are %s in the database. """ % (name, utils.nItems(name, rows)) - f = types.FunctionType(f.func_code, f.func_globals, - f.func_name, closure=f.func_closure) - f.__doc__ = docstring + f = utils.changeFunctionName(f, name, docstring) self.lookupDomains.add(name) setattr(self.__class__, name, f) diff --git a/plugins/RSS.py b/plugins/RSS.py index 1e7c0add1..afeb8d1ff 100644 --- a/plugins/RSS.py +++ b/plugins/RSS.py @@ -40,7 +40,6 @@ import plugins import sets import time -import types from itertools import imap import rssparser @@ -170,9 +169,7 @@ class RSS(callbacks.Privmsg, configurable.Mixin): def f(self, irc, msg, args): args.insert(0, url) self.rss(irc, msg, args) - f = types.FunctionType(f.func_code, f.func_globals, - name, closure=f.func_closure) - f.__doc__ = docstring + f = utils.changeFunctionName(f, name, docstring) f.url = url # Used by __call__. self.feedNames.add(name) setattr(self.__class__, name, f) diff --git a/src/callbacks.py b/src/callbacks.py index 9f12c44a1..ef3371deb 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -47,7 +47,6 @@ import copy import sets import time import shlex -import types import getopt import string import inspect @@ -649,8 +648,7 @@ class Privmsg(irclib.IrcCallback): handleBadArgs() else: handleBadArgs() - dispatcher = types.FunctionType(dispatcher.func_code, - dispatcher.func_globals, canonicalname) + dispatcher = utils.changeFunctionName(dispatcher, canonicalname) if self._original: dispatcher.__doc__ = self._original.__doc__ else: