Closed NtAlexio2 closed 5 months ago
Hi, the proposed solution will break on certain scenarios:
self.getData()
can return a bytes object which may not be a valid unicode string for the selected encodingstdout.encoding => 'utf-8'
self.getData() => b'\xc3'
b'\xc3'.decode('utf-8')
throws an exception: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 0: unexpected end of data
I think that a better approach would be to represent that buffer in an encoding agnostic way, maybe by using binascii.hexlify(self.getData())
Thanks for your review. I applied your suggestion. Please recheck <3
This PR fixes issue reported on #1675. The patch decodes bytes returned from
getData()
by defaultsys.stdout
encoding. The root cause of the bug is drop Python2 supporting.