-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
Prefer io.BytesIO over six; available on all supported Pythons #45388
Conversation
On all supported Pythons, the io.BytesIO is always a stream implementation using an in-memory bytes buffer. Makes code slightly more forward compatible by reducing use of the six module.
@jdufresne Greetings! Thanks for taking the time to open this pullrequest. In order for the community to handle your pullrequest effectively, we need a bit more information. Here are the items we could not find in your description:
Please set the description of this pullrequest with this template: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Note: io.BytesIO and six.BytesIO are different. Not sure yet if that's going to make a difference. Looking into it. |
However, on Python3, they should be the same (and both traceback when given a non-bytes string). We'll have to check that there's nothing here that is only used on python2 before switching. |
Networking team needs to review this for my above question and then can merge it. A quick look and I think:
Note that in any case, this change is not wrong.... it's just that the code which uses it may be incorrect and would need to be fixed so that it doesn't cause an error with this new code. |
If code is passing Unicode strings, then I think |
@jdufresne As I said:
|
Also, in our code base, six.StringIO should not be used with native string type, it should be used with the text type only (just as io.StringIO would be) |
I took a trip through paramiko's source just to be sure, but I feel confident that |
On all supported Pythons, the
io.BytesIO
is always a stream implementation using an in-memory bytes buffer. Makes code slightly more forward compatible by reducing use of the six module.