ccode = compile(cmd, "PDM Input", "eval")
except SyntaxError:
ccode = compile(cmd, "PDM Input", "exec")
- exec ccode in self.mod.__dict__
- self.cl.send("+OK\n")
+ exec(ccode, self.mod.__dict__)
+ self.cl.send(b"+OK\n")
else:
self.echo(eval(ccode, self.mod.__dict__))
- self.cl.send("+OK\n")
+ self.cl.send(b"+OK\n")
except:
- for line in traceback.format_exception(*sys.exc_info()):
- self.cl.send(b" " + line.encode("utf-8"))
+ lines = ("".join(traceback.format_exception(*sys.exc_info()))).split("\n")
+ while len(lines) > 0 and lines[-1] == "": lines = lines[:-1]
+ for line in lines:
- self.cl.send(" " + line + "\n")
- self.cl.send("+EXC\n")
++ self.cl.send(b" " + line.encode("utf-8") + b"\n")
+ self.cl.send(b"+EXC\n")
def handle(self, buf):
- p = buf.find("\n\n")
+ p = buf.find(b"\n\n")
if p < 0:
return buf
cmd = buf[:p + 1]