1

I am receiving a binary stream (over a socket) and converting it to bytearray. After running for about 6hrs (and sometimes even after few minutes) I am getting the following error:

TypeError: string argument without an encoding

on the line:

str = binascii.hexlify(bytearray(result))

The code which is receiving the data and converting it to bytearray is as follows :

try:
    result = so.recv()
    str = binascii.hexlify(bytearray(result))
except:

I referred to the question Python String argument without an encoding and Python 3 documentation but no luck in solving this issue.

Could this be corrupted data in the stream (maybe a network issue)?

Community
  • 1
  • 1
Arpit
  • 4,259
  • 10
  • 38
  • 43
  • 1
    Have you tried wrapping that part into `try/except` and printing the content of `result` in case you get the type error? – tobias_k Jun 30 '16 at 12:35
  • Yes, I have just modified the code section. It is in try/except block. I did try to print "result" but it is printing as special characters on my terminal hence ignored it. (not just for failure case it was true for success case as well). But I did notice that length of result was not as expected (extra by 1byte).. But no expection have been caught. – Arpit Jun 30 '16 at 12:40

0 Answers0