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

bpo-33482: fix codecs.StreamRecoder.writelines #6779

Merged
merged 3 commits into from May 22, 2019

Conversation

@JelleZijlstra
Copy link
Member

@JelleZijlstra JelleZijlstra commented May 13, 2018

A very simple fix. I found this while writing typeshed stubs for StreamRecoder.

https://bugs.python.org/issue33482

JelleZijlstra added a commit to JelleZijlstra/typeshed that referenced this issue May 13, 2018
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 added a commit to JelleZijlstra/typeshed that referenced this issue May 13, 2018
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)
```
@gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Jun 11, 2018

Probably needs a test.

Loading

gvanrossum added a commit to python/typeshed that referenced this issue Jun 11, 2018
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)
```
@JelleZijlstra
Copy link
Member Author

@JelleZijlstra JelleZijlstra commented Jun 12, 2018

Just added a test. (There were no tests at all for StreamRecoder, so I also added a test for the write() method.)

Loading

@JelleZijlstra
Copy link
Member Author

@JelleZijlstra JelleZijlstra commented Jun 12, 2018

The CI errors don't look real.

Loading

yedpodtrzitko pushed a commit to yedpodtrzitko/typeshed that referenced this issue Jan 23, 2019
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)
```
@csabella
Copy link
Contributor

@csabella csabella commented May 22, 2019

@JelleZijlstra, can you fix the merge conflict? That should re-trigger the CI runs. Thanks!

Loading

@JelleZijlstra
Copy link
Member Author

@JelleZijlstra JelleZijlstra commented May 22, 2019

@csabella done, thanks!

Loading

@miss-islington miss-islington merged commit b3be407 into python:master May 22, 2019
5 checks passed
Loading
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented May 22, 2019

Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6.
🐍🍒🤖

Loading

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented May 22, 2019

Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒🤖

Loading

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented May 22, 2019

Sorry, @JelleZijlstra, I could not cleanly backport this to 3.6 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker b3be4072888a4ce054993c2801802721466ea02d 3.6

Loading

@miss-islington miss-islington self-assigned this May 22, 2019
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented May 22, 2019

Sorry, @JelleZijlstra, I could not cleanly backport this to 3.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker b3be4072888a4ce054993c2801802721466ea02d 3.7

Loading

@JelleZijlstra
Copy link
Member Author

@JelleZijlstra JelleZijlstra commented May 22, 2019

I'll open PRs for 3.7 and 3.6.

Loading

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented May 22, 2019

GH-13501 is a backport of this pull request to the 3.6 branch.

Loading

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented May 22, 2019

GH-13502 is a backport of this pull request to the 3.7 branch.

Loading

JelleZijlstra added a commit to JelleZijlstra/cpython that referenced this issue May 22, 2019
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>
miss-islington added a commit that referenced this issue May 22, 2019
)

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants