Merge branch 'master' into python3
authorFredrik Tolf <fredrik@dolda2000.com>
Sat, 19 Jan 2013 00:35:43 +0000 (01:35 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Sat, 19 Jan 2013 00:40:55 +0000 (01:40 +0100)
Conflicts:
pdm/srv.py

1  2 
pdm/srv.py

diff --cc pdm/srv.py
@@@ -56,18 -55,20 +56,20 @@@ class repl(object)
                  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]