Skip to content

Commit

Permalink
added PR invisibleroads#158 by oguzhanogreden
Browse files Browse the repository at this point in the history
  • Loading branch information
Nakroma committed Jun 12, 2017
1 parent 71647a3 commit 8ec7309
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions socketIO_client/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,14 @@ def _make_packet_prefix(packet):


def _read_packet_length(content, content_index):
while get_byte(content, content_index) != 0:
while content.decode()[content_index] != ':':
content_index += 1
content_index += 1
packet_length_string = ''
byte = get_byte(content, content_index)
while byte != 255:
packet_length_string += str(byte)
content_index += 1
byte = get_byte(content, content_index)
packet_length_string = content.decode()[0:content_index]

This comment has been minimized.

Copy link
@anonimous321

anonimous321 Sep 30, 2017

I think there should be content.decode()[<2nd function argument>:content_index], not just content.decode()[0:content_index], because I'm periodically getting errors like

File "/usr/lib/python3.6/site-packages/socketIO_client/parsers.py", line 127, in _read_packet_length
return content_index, int(packet_length_string)
ValueError: invalid literal for int() with base 10: '2:4013'

and applying this patch seems to fix that.

This comment has been minimized.

Copy link
@Nakroma

Nakroma Oct 2, 2017

Author Member

Could you provide a short code snippet to reproduce the error?

This comment has been minimized.

Copy link
@Nakroma

Nakroma Oct 5, 2017

Author Member

The patch is committed and uploaded :) Thanks for reporting and fixing the bug

return content_index, int(packet_length_string)


def _read_packet_text(content, content_index, packet_length):
while get_byte(content, content_index) == 255:
while content.decode()[content_index] == ':':
content_index += 1
packet_text = content[content_index:content_index + packet_length]
return content_index + packet_length, packet_text

0 comments on commit 8ec7309

Please sign in to comment.