Commits

Victor Stinner committed 450209e

Issue #12400: regrtest.runtest() uses stream.seek(0) before .truncate()

.truncate(0) doesn't rewind.

  • Participants
  • Parent commits bc2f3fb
  • Branches 3.2

Comments (0)

Files changed (1)

Lib/test/regrtest.py

             # tests keep a reference to sys.stdout or sys.stderr
             # (eg. test_argparse).
             if runtest.stringio is None:
-                runtest.stringio = io.StringIO()
-            stream = runtest.stringio
-            stream.truncate(0)
+                stream = io.StringIO()
+                runtest.stringio = stream
+            else:
+                stream = runtest.stringio
+                stream.seek(0)
+                stream.truncate()
 
             orig_stdout = sys.stdout
             orig_stderr = sys.stderr