FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-43680: _pyio.open() becomes a static method by vstinner · Pull Request #25354 · python/cpython · GitHub

/ cpython Public

bpo-43680: _pyio.open() becomes a static method - #25354

Merged
vstinner merged 3 commits into
python:masterfrom
vstinner:pyio_openwrapper
Apr 12, 2021
Merged

bpo-43680: _pyio.open() becomes a static method#25354
vstinner merged 3 commits into
python:masterfrom
vstinner:pyio_openwrapper

Conversation

vstinner commented Apr 12, 2021
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

The Python _pyio.open() function becomes a static method to behave as
io.open() built-in function: don't become a bound method when stored
as a class variable. It becomes possible since static methods are now
callable in Python 3.10. Moreover, _pyio.OpenWrapper becomes a simple
alias to _pyio.open.

init_set_builtins_open() now sets builtins.open to io.open, rather
than setting it to io.OpenWrapper, since OpenWrapper is now an alias
to open in the io and _pyio modules.

https://bugs.python.org/issue43680

The Python _pyio.open() function becomes a static method to behave as
io.open() built-in function: don't become a bound method when stored
as a class variable. It becomes possible since static methods are now
callable in Python 3.10. Moreover, _pyio.OpenWrapper becomes a simple
alias to _pyio.open.

init_set_builtins_open() now sets builtins.open to io.open, rather
than setting it to io.OpenWrapper, since OpenWrapper is now an alias
to open in the io and _pyio modules.

Copy link
Copy Markdown
Member Author

@methane: Would you mind to review this change?

Thanks to https://bugs.python.org/issue43682, it becomes possible to put @staticmethod on _pyio.open. I propose to start with this change. Then I will propose a change to deprecate io.OpenWrapper and _pyio.OpenWrapper.

methane left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM except one nitpick.

vstinner merged commit 77d668b into python:master Apr 12, 2021
vstinner deleted the pyio_openwrapper branch April 12, 2021 08:46

methane commented Apr 14, 2021

Copy link
Copy Markdown
Member

Can we remove DocDescriptor too?

It is not defined in C _io module. So I think it is safe to remove.

Copy link
Copy Markdown
Member Author

Can we remove DocDescriptor too?
It is not defined in C _io module. So I think it is safe to remove.

Sure, it was not documented and doesn't exist in the io module. I already removed it: 3bc694d

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

4 participants


Back | FazBrowse Home | New Git URL