Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

base_connection.buffer is a list of bytes, rather than a bytes #117

Closed
LivInTheLookingGlass opened this issue Dec 1, 2016 · 5 comments
Closed

Comments

@LivInTheLookingGlass
Copy link
Collaborator

LivInTheLookingGlass commented Dec 1, 2016

For context, see end of #116

@the-zebulan
Copy link
Contributor

Ok, looks like I have some reading to do on bytes. Do you mean replace it with a bytearray?

@LivInTheLookingGlass
Copy link
Collaborator Author

LivInTheLookingGlass commented Dec 1, 2016 via email

@the-zebulan
Copy link
Contributor

the-zebulan commented Dec 1, 2016

Ok, thanks for the tip. Ya, it looks like bytes is immutable and bytearray is mutable (append and such). I was just looking at the base_connection code and saw self.buffer.append(data) so that's why I asked about bytesarray.

I'm just about to head to bed but I will mess around with it in the morning and try to get it working!

@LivInTheLookingGlass
Copy link
Collaborator Author

Just tinkered around a little.

There are going to be two things of note, it looks like.

  1. Python 3 is more restrictive here than python 2. You'll probably want to test in there before anything else

  2. You want bytearray.extend, not bytearray.append. And you want to use array slicing rather than pop. So: bytes(barray[0:x])

@the-zebulan
Copy link
Contributor

Interesting. Ok, thanks for the tips!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants