mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-24 11:42:52 +01:00
Debug: Fix Python 3 compatibility. Closes GH-565.
This commit is contained in:
parent
c6cb4fa394
commit
8b8265522c
@ -43,12 +43,12 @@ __author__ = supybot.authors.jemfinch
|
|||||||
# contributions.
|
# contributions.
|
||||||
__contributors__ = {}
|
__contributors__ = {}
|
||||||
|
|
||||||
import config
|
from . import config
|
||||||
import plugin
|
from . import plugin
|
||||||
reload(plugin) # In case we're being reloaded.
|
reload(plugin) # In case we're being reloaded.
|
||||||
|
|
||||||
if world.testing:
|
if world.testing:
|
||||||
import test
|
from . import test
|
||||||
|
|
||||||
Class = plugin.Class
|
Class = plugin.Class
|
||||||
configure = config.configure
|
configure = config.configure
|
||||||
|
@ -47,7 +47,7 @@ except ImportError: # Python 3
|
|||||||
class exceptions:
|
class exceptions:
|
||||||
"""Pseudo-module"""
|
"""Pseudo-module"""
|
||||||
pass
|
pass
|
||||||
for (key, value) in exceptions.__dict__.items():
|
for (key, value) in list(exceptions.__dict__.items()):
|
||||||
if isinstance(value, type) and issubclass(value, Exception):
|
if isinstance(value, type) and issubclass(value, Exception):
|
||||||
exceptions[key] = value
|
exceptions[key] = value
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ def getTracer(fd):
|
|||||||
def tracer(frame, event, _):
|
def tracer(frame, event, _):
|
||||||
if event == 'call':
|
if event == 'call':
|
||||||
code = frame.f_code
|
code = frame.f_code
|
||||||
print >>fd, '%s: %s' % (code.co_filename, code.co_name)
|
fd.write('%s: %s\n' % (code.co_filename, code.co_name))
|
||||||
return tracer
|
return tracer
|
||||||
|
|
||||||
class Debug(callbacks.Privmsg):
|
class Debug(callbacks.Privmsg):
|
||||||
@ -98,7 +98,7 @@ class Debug(callbacks.Privmsg):
|
|||||||
self._evalEnv['__'] = self._evalEnv['_']
|
self._evalEnv['__'] = self._evalEnv['_']
|
||||||
self._evalEnv['_'] = x
|
self._evalEnv['_'] = x
|
||||||
irc.reply(repr(x))
|
irc.reply(repr(x))
|
||||||
except SyntaxError, e:
|
except SyntaxError as e:
|
||||||
irc.reply(format('%s: %q', utils.exnToString(e), s))
|
irc.reply(format('%s: %q', utils.exnToString(e), s))
|
||||||
eval = wrap(eval, ['text'])
|
eval = wrap(eval, ['text'])
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ class Debug(callbacks.Privmsg):
|
|||||||
|
|
||||||
Execs <code>. Returns success if it didn't raise any exceptions.
|
Execs <code>. Returns success if it didn't raise any exceptions.
|
||||||
"""
|
"""
|
||||||
exec s
|
exec(s)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
_exec = wrap(_exec, ['text'])
|
_exec = wrap(_exec, ['text'])
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ class Debug(callbacks.Privmsg):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
irc.reply(repr(eval(text)))
|
irc.reply(repr(eval(text)))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
irc.reply(utils.exnToString(e))
|
irc.reply(utils.exnToString(e))
|
||||||
simpleeval = wrap(simpleeval, ['text'])
|
simpleeval = wrap(simpleeval, ['text'])
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ class Debug(callbacks.Privmsg):
|
|||||||
exn = __builtins__[name]
|
exn = __builtins__[name]
|
||||||
else:
|
else:
|
||||||
exn = getattr(__builtins__, name)
|
exn = getattr(__builtins__, name)
|
||||||
raise exn, msg.prefix
|
raise exn(msg.prefix)
|
||||||
exn = wrap(exn, ['text'])
|
exn = wrap(exn, ['text'])
|
||||||
|
|
||||||
def sendquote(self, irc, msg, args, text):
|
def sendquote(self, irc, msg, args, text):
|
||||||
@ -184,7 +184,7 @@ class Debug(callbacks.Privmsg):
|
|||||||
while times:
|
while times:
|
||||||
L.append(gc.collect())
|
L.append(gc.collect())
|
||||||
times -= 1
|
times -= 1
|
||||||
irc.reply(format('%L', map(str, L)))
|
irc.reply(format('%L', list(map(str, L))))
|
||||||
collect = wrap(collect, [additional('positiveInt', 1)])
|
collect = wrap(collect, [additional('positiveInt', 1)])
|
||||||
|
|
||||||
_progstats_endline_remover = utils.str.MultipleRemover('\r\n')
|
_progstats_endline_remover = utils.str.MultipleRemover('\r\n')
|
||||||
|
Loading…
Reference in New Issue
Block a user