bpo-43510: Remove _pyio.OpenWrapper class#25107
bpo-43510: Remove _pyio.OpenWrapper class#25107methane wants to merge 5 commits intopython:masterfrom
Conversation
Lib/_pyio.py
Outdated
| # Emit the EncodingWarning for the caller. | ||
| if "b" not in mode: | ||
| encoding = text_encoding(encoding) | ||
| return open(file, mode, buffering, encoding, *args, **kwargs) |
There was a problem hiding this comment.
Are you checking this here instead of leaving it up to the open call in order to raise the warning at the right stack level?
There was a problem hiding this comment.
Yes. text_encoding() is used for it.
There was a problem hiding this comment.
Okay, so this is just a particular problem in an unusual case of a proxy call that needs to bring the text_encoding call forward, with special handling such as checking if "b" not in mode.
|
OpenWrapper is really a weird beast. I don't know other functions which are defined this way. Can't we decorate The io module doesn't use this hack: OpenWrapper is just an alias to open. |
Nice idea. |
|
Oh, test is failing... |
|
I opened a discussion on python-dev about OpenWrapper and staticmethod: https://mail.python.org/archives/list/[email protected]/thread/QZ7SFW3IW3S2C5RMRJZOOUFSHHUINNME/ |
And I created https://bugs.python.org/issue43680 to remove undocumented io.OpenWrapper and _pyio.OpenWrapper. |
|
Maybe define |
https://bugs.python.org/issue43510