bpo-33482: fix codecs.StreamRecoder.writelines#6779
bpo-33482: fix codecs.StreamRecoder.writelines#6779miss-islington merged 3 commits intopython:masterfrom
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 <jelle.zijlstra@gmail.com>
) 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 <jelle.zijlstra@gmail.com> https://bugs.python.org/issue33482
A very simple fix. I found this while writing typeshed stubs for StreamRecoder.
https://bugs.python.org/issue33482