In Python 3, sys.stdout.write expects a string rather than bytes. In order to be able to write the bytes to stdout, we need to use the buffer directly instead. This change is borrowing the implementation for writing to stdout that cat.py uses. Note that we cannot use cat.py directly because the file we are trying to open is a gzip file.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
thanks!
@stella.stamenova - do i understand correctly that the new version works correctly with both - python2 and python3 ? (just in case)
Comment Actions
What would the consequence be of just converting the bytes to a string and writing that out? I have neither a windows box nor python 3 installed.
Comment Actions
I suppose we could try a conversion, but we would have to make a guess on the encoding and that could be a problem also. Do you see a benefit in doing a byte to string conversion over writing the bytes to the buffer?
Comment Actions
The reason for it was just that this all seemed too complicated to me for "something so simple" but now that I've looked into the problem I think what you've done makes perfect sense.