Skip to content

bpo-38066: Hide internal Stream methods#15762

Merged
miss-islington merged 4 commits into
python:masterfrom
asvetlov:hide-private-streams-api
Sep 10, 2019
Merged

bpo-38066: Hide internal Stream methods#15762
miss-islington merged 4 commits into
python:masterfrom
asvetlov:hide-private-streams-api

Conversation

@asvetlov

@asvetlov asvetlov commented Sep 9, 2019

Copy link
Copy Markdown
Contributor

feed_eof(), feed_data(), set_exception(), and set_transport() are prefixed with underscore now.

https://bugs.python.org/issue38066

Automerge-Triggered-By: @asvetlov

@1st1

1st1 commented Sep 9, 2019

Copy link
Copy Markdown
Member

@asvetlov Andrew, can we also remove the Stream.transport property?

@asvetlov

asvetlov commented Sep 9, 2019

Copy link
Copy Markdown
Contributor Author

I think we can but it makes subprocess API a little less backward compatible.
Really wonder how much code is broken.
I'm working on backward-compatible approach: keep all mentioned method plus transport with underscore-prefixed version for internal usage and public version for backward compatibility that raises DeprecationWarding. It is the safest approach that we can do.

@1st1

1st1 commented Sep 9, 2019

Copy link
Copy Markdown
Member

But asyncio.Stream is a new thing - what backward compatibility problems do we have with it?

@asvetlov

asvetlov commented Sep 9, 2019

Copy link
Copy Markdown
Contributor Author

create_subprocess_exec / create_subprocess_exec used to work with StreamReader/StreamWriter, now they use asyncio.Stream. The replacement is drop-in, Stream has all API methods from reader and writer.

@1st1

1st1 commented Sep 9, 2019

Copy link
Copy Markdown
Member

Ah, right! Then your approach with deprecating them gracefully works. Don't forget to also update the docs.

@asvetlov

asvetlov commented Sep 9, 2019

Copy link
Copy Markdown
Contributor Author

Legacy methods are restored with emitting deprecation warnings.

Comment thread Lib/asyncio/streams.py

@property
def transport(self):
warnings.warn("Stream.transport attribute is deprecated "

@asvetlov asvetlov Sep 9, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

asyncio itself never uses this property, there is no need for readonly internal API version

Comment thread Lib/asyncio/streams.py
# The helper tries to use fast-path to return already existing
# complete future object if underlying transport is not paused
#and actual waiting for writing resume is not needed
# and actual waiting for writing resume is not needed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it's ok to fix this unrelated comment spacing here. Don't worth a separate PR

@aeros aeros left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the PR @asvetlov.

I have a couple of minor grammar suggestions.

Comment thread Lib/asyncio/streams.py Outdated
Comment thread Lib/asyncio/streams.py
@@ -1366,7 +1371,7 @@ def writelines(self, data):
def _fast_drain(self):
# The helper tries to use fast-path to return already existing
# complete future object if underlying transport is not paused

@aeros aeros Sep 10, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unrelated to the PR, but could make a minor grammar fix here? I could make further suggestions to the phrasing of the code comments for this method, but I figured this suggestion would be easier and uncontroversial.

Suggested change
# complete future object if underlying transport is not paused
# complete future object if the underlying transport is not paused

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fast drain works with the single object, not multiple ones.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fast drain works with the single object, not multiple ones.

Oops, I'll adjust the suggestion.

@1st1

1st1 commented Sep 10, 2019

Copy link
Copy Markdown
Member

Great!

@miss-islington
miss-islington merged commit 12c122a into python:master Sep 10, 2019
@miss-islington

Copy link
Copy Markdown
Contributor

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 10, 2019
feed_eof(), feed_data(), set_exception(), and set_transport() are prefixed with underscore now.

https://bugs.python.org/issue38066
(cherry picked from commit 12c122a)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
@bedevere-bot

Copy link
Copy Markdown

GH-15847 is a backport of this pull request to the 3.8 branch.

@asvetlov
asvetlov deleted the hide-private-streams-api branch September 10, 2019 12:56
miss-islington added a commit that referenced this pull request Sep 10, 2019
feed_eof(), feed_data(), set_exception(), and set_transport() are prefixed with underscore now.

https://bugs.python.org/issue38066
(cherry picked from commit 12c122a)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
websurfer5 pushed a commit to websurfer5/cpython that referenced this pull request Jul 20, 2020
feed_eof(), feed_data(), set_exception(), and set_transport() are prefixed with underscore now.


https://bugs.python.org/issue38066
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants