-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-43510: Remove _pyio.OpenWrapper class #25107
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. text_encoding() is used for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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