Converted to not use the new module but the types module instead.

This commit is contained in:
Jeremy Fincher 2003-10-30 03:46:31 +00:00
parent 8d04bdbcb6
commit bc6f4bd149
2 changed files with 6 additions and 5 deletions

View File

@ -36,8 +36,8 @@ Allows 'aliases' for other commands.
import plugins import plugins
import re import re
import new
import sets import sets
import types
import conf import conf
import debug import debug
@ -148,7 +148,8 @@ def makeNewAlias(name, alias):
alias_ = atRe.sub(replace, alias_) alias_ = atRe.sub(replace, alias_)
alias_ = alias_.replace('$*', ' '.join(map(utils.dqrepr, args))) alias_ = alias_.replace('$*', ' '.join(map(utils.dqrepr, args)))
self.Proxy(irc.irc, msg, callbacks.tokenize(alias_)) self.Proxy(irc.irc, msg, callbacks.tokenize(alias_))
f = new.function(f.func_code, f.func_globals, name, closure=f.func_closure) f = types.FunctionType(f.func_code, f.func_globals,
name, closure=f.func_closure)
f.__doc__ ='<an alias, %s>\n\nAlias for %r' % \ f.__doc__ ='<an alias, %s>\n\nAlias for %r' % \
(utils.nItems(biggestDollar, 'argument'), alias) (utils.nItems(biggestDollar, 'argument'), alias)
return f return f

View File

@ -36,9 +36,9 @@ Various math-related commands.
import plugins import plugins
import re import re
import new
import math import math
import cmath import cmath
import types
import string import string
from itertools import imap from itertools import imap
@ -77,7 +77,7 @@ class Math(callbacks.Privmsg):
# Then we delete all square brackets, underscores, and whitespace, so no # Then we delete all square brackets, underscores, and whitespace, so no
# one can do list comprehensions or call __...__ functions. # one can do list comprehensions or call __...__ functions.
### ###
_mathEnv = {'__builtins__': new.module('__builtins__'), 'i': 1j} _mathEnv = {'__builtins__': types.ModuleType('__builtins__'), 'i': 1j}
_mathEnv.update(math.__dict__) _mathEnv.update(math.__dict__)
_mathEnv.update(cmath.__dict__) _mathEnv.update(cmath.__dict__)
_mathRe = re.compile(r'((?:(?<![A-Fa-f\d])-)?' _mathRe = re.compile(r'((?:(?<![A-Fa-f\d])-)?'
@ -207,7 +207,7 @@ class Math(callbacks.Privmsg):
s = ', '.join(imap(self._complexToString, imap(complex, stack))) s = ', '.join(imap(self._complexToString, imap(complex, stack)))
irc.reply(msg, 'Stack: [%s]' % s) irc.reply(msg, 'Stack: [%s]' % s)
_convertEnv = {'__builtins__': new.module('__builtins__')} _convertEnv = {'__builtins__': types.ModuleType('__builtins__')}
for (k, v) in unum.units.__dict__.iteritems(): for (k, v) in unum.units.__dict__.iteritems():
if isinstance(v, unum.Unum): if isinstance(v, unum.Unum):
_convertEnv[k.lower()] = v _convertEnv[k.lower()] = v