]> granicus.if.org Git - python/commitdiff
Issue #12400: regrtest.runtest() uses stream.seek(0) before .truncate()
authorVictor Stinner <victor.stinner@haypocalc.com>
Wed, 29 Jun 2011 18:01:29 +0000 (20:01 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Wed, 29 Jun 2011 18:01:29 +0000 (20:01 +0200)
.truncate(0) doesn't rewind.

Lib/test/regrtest.py

index f1ef7156103c1368246a8d8bc31dae0d74c6637d..14fa00591b96130c575a5d1407930570961bfe62 100755 (executable)
@@ -791,9 +791,12 @@ def runtest(test, verbose, quiet,
             # 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