subunit fails to write to stream when write() returns None
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
subunit |
New
|
Undecided
|
Unassigned | ||
testtools |
New
|
Undecided
|
Unassigned |
Bug Description
A purely implement filelike object doesn't implements write method without returning None instead of the actual number of written bytes. This would make below code to broke on python >= 3. becouse trying to sum None to an integer.
# On eventlet 0.17.3, GreenIO.write() can make partial write.
# Use a loop to ensure that all bytes are written.
# See also the eventlet issue:
# https:/
view = memoryview(data)
datalen = len(data)
offset = 0
while offset < datalen:
written = self.output_
offset += written
The workaround for such problem is to check value returned from write method and if it is None to assume all bytes has been written.
while offset < datalen:
written = self.output_
if written is None:
break
offset += written