Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

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 pull request 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 pull request 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

Probably needs a test.

gvanrossum pushed a commit to python/typeshed that referenced this pull request 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

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

@JelleZijlstra
Copy link
Member Author

The CI errors don't look real.

yedpodtrzitko pushed a commit to yedpodtrzitko/typeshed that referenced this pull request 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

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

@JelleZijlstra
Copy link
Member Author

@csabella done, thanks!

@miss-islington
Copy link
Contributor

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

@miss-islington
Copy link
Contributor

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

@miss-islington
Copy link
Contributor

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

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

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

@JelleZijlstra
Copy link
Member Author

I'll open PRs for 3.7 and 3.6.

@bedevere-bot
Copy link

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

@bedevere-bot
Copy link

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

JelleZijlstra added a commit to JelleZijlstra/cpython that referenced this pull request 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 <[email protected]>
miss-islington pushed a commit that referenced this pull request 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 <[email protected]>





https://bugs.python.org/issue33482
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants