diff --git a/changelog/727.bugfix.rst b/changelog/727.bugfix.rst new file mode 100644 index 0000000000..04e74a8938 --- /dev/null +++ b/changelog/727.bugfix.rst @@ -0,0 +1 @@ +The reading of command output sometimes failed with ``IOError: [Errno 0] Error`` on Windows, this was fixed by using a simpler method to update the read buffers. \ No newline at end of file diff --git a/tox/session.py b/tox/session.py index 2754787243..8da050f76c 100644 --- a/tox/session.py +++ b/tox/session.py @@ -135,7 +135,7 @@ def popen(self, args, cwd=None, env=None, redirect=True, returnout=False, ignore fout.write("actionid: %s\nmsg: %s\ncmdargs: %r\n\n" % (self.id, self.msg, args)) fout.flush() outpath = py.path.local(fout.name) - fin = outpath.open() + fin = outpath.open('rb') fin.read() # read the header, so it won't be written to stdout stdout = fout elif returnout: @@ -163,7 +163,6 @@ def popen(self, args, cwd=None, env=None, redirect=True, returnout=False, ignore out = None last_time = time.time() while 1: - fin_pos = fin.tell() # we have to read one byte at a time, otherwise there # might be no output for a long time with slow tests data = fin.read(1) @@ -181,7 +180,8 @@ def popen(self, args, cwd=None, env=None, redirect=True, returnout=False, ignore break else: time.sleep(0.1) - fin.seek(fin_pos) + # the seek updates internal read buffers + fin.seek(0, 1) fin.close() else: out, err = popen.communicate()