diff --git a/src/callbacks.py b/src/callbacks.py index a97cee9eb..3e1f86e01 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -41,11 +41,11 @@ how to use them. import fix import re -import new import copy import sets import time import shlex +import types import getopt import string import inspect @@ -657,7 +657,8 @@ class Privmsg(irclib.IrcCallback): handleBadArgs() else: handleBadArgs() - dispatcher = new.function(dispatcher.func_code,globals(),canonicalname) + dispatcher = types.FunctionType(dispatcher.func_code, + dispatcher.func_globals, canonicalname) if self._original: dispatcher.__doc__ = self._original.__doc__ else: diff --git a/src/plugins.py b/src/plugins.py index 203913462..6f133a515 100644 --- a/src/plugins.py +++ b/src/plugins.py @@ -32,10 +32,10 @@ import fix import os -import new import sys import sets import time +import types import urllib2 import threading @@ -254,9 +254,9 @@ class Toggleable(object): code = self.toggle.im_func.func_code globals = self.toggle.im_func.func_globals closure = self.toggle.im_func.func_closure - newf = new.function(code, globals, None, closure=closure) + newf = types.FunctionType(code, globals, None, closure=closure) newf.__doc__ = s - self.toggle = new.instancemethod(newf, self, self.__class__) + self.toggle = types.MethodType(newf, self, self.__class__) def _toggleNames(self): names = self.toggles.defaults.keys() @@ -264,6 +264,10 @@ class Toggleable(object): return utils.commaAndify(map(repr, names)) def toggle(self, irc, msg, args): + """[] [] + + The author of my plugin didn't call Toggleable.__init__. + """ try: channel = privmsgs.getChannel(msg, args) capability = ircdb.makeChannelCapability(channel, 'op') diff --git a/src/privmsgs.py b/src/privmsgs.py index 93b50068a..f141c1636 100644 --- a/src/privmsgs.py +++ b/src/privmsgs.py @@ -35,7 +35,7 @@ Includes various accessories for callbacks.Privmsg based callbacks. import fix -import new +import types import conf import ircdb @@ -84,8 +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, closure=newf.func_closure) + newf = types.FunctionType(newf.func_code, newf.func_globals, + f.func_name, closure=newf.func_closure) newf.__doc__ = f.__doc__ return newf @@ -99,23 +99,23 @@ def checkChannelCapability(f, capability): chancap = ircdb.makeChannelCapability(channel, capability) if ircdb.checkCapability(msg.prefix, chancap): L += (channel,) - ff = new.instancemethod(f, self, self.__class__) + ff = types.MethodType(f, self, self.__class__) ff(irc, msg, args, *L) else: irc.error(msg, conf.replyNoCapability % chancap) - newf = new.function(newf.func_code, newf.func_globals, - f.func_name, closure=newf.func_closure) + newf = types.FunctionType(newf.func_code, newf.func_globals, + f.func_name, closure=newf.func_closure) newf.__doc__ = f.__doc__ return newf def thread(f): """Makes sure a command spawns a thread when called.""" def newf(self, irc, msg, args, *L): - ff = new.instancemethod(f, self, self.__class__) + ff = types.MethodType(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, closure=newf.func_closure) + newf = types.FunctionType(newf.func_code, newf.func_globals, + f.func_name, closure=newf.func_closure) newf.__doc__ = f.__doc__ return newf @@ -131,10 +131,10 @@ def name(f): else: name = msg.prefix L = (name,) + L - ff = new.instancemethod(f, self, self.__class__) + ff = types.MethodType(f, self, self.__class__) ff(irc, msg, args, *L) - newf = new.function(newf.func_code, newf.func_globals, - f.func_name, closure=newf.func_closure) + newf = types.FunctionType(newf.func_code, newf.func_globals, + f.func_name, closure=newf.func_closure) newf.__doc__ = f.__doc__ return newf @@ -143,10 +143,10 @@ def channel(f): def newf(self, irc, msg, args, *L): channel = getChannel(msg, args) L = (channel,) + L - ff = new.instancemethod(f, self, self.__class__) + ff = types.MethodType(f, self, self.__class__) ff(irc, msg, args, *L) - newf = new.function(newf.func_code, newf.func_globals, - f.func_name, closure=newf.func_closure) + newf = types.FunctionType(newf.func_code, newf.func_globals, + f.func_name, closure=newf.func_closure) newf.__doc__ = f.__doc__ return newf