py3: don't use traceback.print_exc() in commandserver.py
authorYuya Nishihara <yuya@tcha.org>
Tue, 16 Oct 2018 08:41:58 +0200
changeset 40361 b7de186efd82
parent 40360 dee73a97e132
child 40362 2f1edf5e0a4b
py3: don't use traceback.print_exc() in commandserver.py It doesn't support a bytes stream on Python 3. This makes a traceback being sent by one frame, but that shouldn't matter.
mercurial/commandserver.py
tests/test-commandserver.t
--- a/mercurial/commandserver.py	Tue Oct 16 08:29:24 2018 +0200
+++ b/mercurial/commandserver.py	Tue Oct 16 08:41:58 2018 +0200
@@ -369,7 +369,7 @@
             cerr = sv.cerr
         else:
             cerr = channeledoutput(fout, 'e')
-        traceback.print_exc(file=cerr)
+        cerr.write(encoding.strtolocal(traceback.format_exc()))
         raise
     finally:
         fin.close()
--- a/tests/test-commandserver.t	Tue Oct 16 08:29:24 2018 +0200
+++ b/tests/test-commandserver.t	Tue Oct 16 08:41:58 2018 +0200
@@ -786,8 +786,9 @@
   ...     while True:
   ...         try:
   ...             ch, data = readchannel(conn)
-  ...             if not data.startswith(b'  '):
-  ...                 bprint(b'%c, %r' % (ch, data))
+  ...             for l in data.splitlines(True):
+  ...                 if not l.startswith(b'  '):
+  ...                     bprint(b'%c, %r' % (ch, l))
   ...         except EOFError:
   ...             break
   >>> check(earlycrash, server.connect)