Skip to content

Commit 659fd14

Browse files
fschulzegaborbernat
authored andcommitted
Fix issue #727: 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. (#734)
1 parent 0eeab6f commit 659fd14

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Cyril Roelandt
1818
Eli Collins
1919
Eugene Yunak
2020
Fernando L. Pereira
21+
Florian Schulze
2122
Hazal Ozturk
2223
Henk-Jaap Wagenaar
2324
Ian Stapleton Cordasco

changelog/727.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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. - by @fschulze

tox/session.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def popen(self, args, cwd=None, env=None, redirect=True, returnout=False, ignore
135135
fout.write("actionid: %s\nmsg: %s\ncmdargs: %r\n\n" % (self.id, self.msg, args))
136136
fout.flush()
137137
outpath = py.path.local(fout.name)
138-
fin = outpath.open()
138+
fin = outpath.open('rb')
139139
fin.read() # read the header, so it won't be written to stdout
140140
stdout = fout
141141
elif returnout:
@@ -163,13 +163,12 @@ def popen(self, args, cwd=None, env=None, redirect=True, returnout=False, ignore
163163
out = None
164164
last_time = time.time()
165165
while 1:
166-
fin_pos = fin.tell()
167166
# we have to read one byte at a time, otherwise there
168167
# might be no output for a long time with slow tests
169168
data = fin.read(1)
170169
if data:
171170
sys.stdout.write(data)
172-
if '\n' in data or (time.time() - last_time) > 1:
171+
if b'\n' in data or (time.time() - last_time) > 1:
173172
# we flush on newlines or after 1 second to
174173
# provide quick enough feedback to the user
175174
# when printing a dot per test
@@ -181,7 +180,8 @@ def popen(self, args, cwd=None, env=None, redirect=True, returnout=False, ignore
181180
break
182181
else:
183182
time.sleep(0.1)
184-
fin.seek(fin_pos)
183+
# the seek updates internal read buffers
184+
fin.seek(0, 1)
185185
fin.close()
186186
else:
187187
out, err = popen.communicate()

0 commit comments

Comments
 (0)