Steve Borho committed 9b454cc

hgtk: keep pointer to our cStringIO instance

If the launched application overrides sys.stderr itself, we may
crash when we try to call seek() on it. So keep a pointer to
the cStringIO.StringIO instance we allocated and use it directly.

Fixes tracebacks from launching Qct as external commit tool

Comments (0)

Files changed (1)

     import cStringIO
-    sys.stderr = cStringIO.StringIO()
+    mystderr = cStringIO.StringIO()
+    sys.stderr = mystderr
     ret = hggtk.hgtk.dispatch(sys.argv[1:])
-    for l in sys.stderr.readlines():
+    for l in mystderr.readlines():
         if l.startswith('Traceback') or l.startswith('TypeError'):
             from hggtk.bugreport import run
             from hggtk.hgtk import gtkrun
             from mercurial import ui
-            error = 'Recoverable runtime error (stderr):\n' +
+            error = 'Recoverable runtime error (stderr):\n' +
             opts = {}
             opts['cmd'] = ' '.join(sys.argv[1:])
             opts['error'] = error