-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-33482: fix codecs.StreamRecoder.writelines #6779
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
Conversation
Started out as progress towards python#1476, but I ended up fixing a few more things: - fixed the signature of _encode_type, which actually returns a pair, not a string - made some attributes into properties in order to prevent the descriptor protocol from turning them into methods - found a bug in CPython in the process (python/cpython#6779) I used the following test file to make sure these classes are now instantiable: ```python import codecs import io from typing import IO bio = io.BytesIO() cod = codecs.lookup('utf-8') codecs.StreamReaderWriter(bio, codecs.StreamReader, codecs.StreamWriter) codecs.StreamRecoder(bio, cod.encode, cod.decode, codecs.StreamReader, codecs.StreamWriter) ```
Started out as progress towards python#1476, but I ended up fixing a few more things: - fixed the signature of _encode_type, which actually returns a pair, not a string - made some attributes into properties in order to prevent the descriptor protocol from turning them into methods - found a bug in CPython in the process (python/cpython#6779) I used the following test file to make sure these classes are now instantiable: ```python import codecs import io from typing import IO bio = io.BytesIO() cod = codecs.lookup('utf-8') codecs.StreamReaderWriter(bio, codecs.StreamReader, codecs.StreamWriter) codecs.StreamRecoder(bio, cod.encode, cod.decode, codecs.StreamReader, codecs.StreamWriter) ```
Probably needs a test. |
Started out as progress towards #1476, but I ended up fixing a few more things: - fixed the signature of _encode_type, which actually returns a pair, not a string - made some attributes into properties in order to prevent the descriptor protocol from turning them into methods - found a bug in CPython in the process (python/cpython#6779) I used the following test file to make sure these classes are now instantiable: ```python import codecs import io from typing import IO bio = io.BytesIO() cod = codecs.lookup('utf-8') codecs.StreamReaderWriter(bio, codecs.StreamReader, codecs.StreamWriter) codecs.StreamRecoder(bio, cod.encode, cod.decode, codecs.StreamReader, codecs.StreamWriter) ```
Just added a test. (There were no tests at all for StreamRecoder, so I also added a test for the write() method.) |
The CI errors don't look real. |
Started out as progress towards python#1476, but I ended up fixing a few more things: - fixed the signature of _encode_type, which actually returns a pair, not a string - made some attributes into properties in order to prevent the descriptor protocol from turning them into methods - found a bug in CPython in the process (python/cpython#6779) I used the following test file to make sure these classes are now instantiable: ```python import codecs import io from typing import IO bio = io.BytesIO() cod = codecs.lookup('utf-8') codecs.StreamReaderWriter(bio, codecs.StreamReader, codecs.StreamWriter) codecs.StreamRecoder(bio, cod.encode, cod.decode, codecs.StreamReader, codecs.StreamWriter) ```
@JelleZijlstra, can you fix the merge conflict? That should re-trigger the CI runs. Thanks! |
@csabella done, thanks! |
Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6. |
Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
Sorry, @JelleZijlstra, I could not cleanly backport this to |
Sorry, @JelleZijlstra, I could not cleanly backport this to |
I'll open PRs for 3.7 and 3.6. |
GH-13501 is a backport of this pull request to the 3.6 branch. |
GH-13502 is a backport of this pull request to the 3.7 branch. |
A very simple fix. I found this while writing typeshed stubs for StreamRecoder. https://bugs.python.org/issue33482. (cherry picked from commit b3be407) Co-authored-by: Jelle Zijlstra <[email protected]>
) A very simple fix. I found this while writing typeshed stubs for StreamRecoder. https://bugs.python.org/issue33482. (cherry picked from commit b3be407) Co-authored-by: Jelle Zijlstra <[email protected]> https://bugs.python.org/issue33482
A very simple fix. I found this while writing typeshed stubs for StreamRecoder.
https://bugs.python.org/issue33482