-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
bpo-45351: Print all addresses #28828
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
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). CLA MissingOur records indicate the following people have not signed the CLA: For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. If you have recently signed the CLA, please wait at least one business day You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
Doc/library/asyncio-stream.rst
Outdated
@@ -395,8 +395,8 @@ TCP echo server using the :func:`asyncio.start_server` function:: | |||
server = await asyncio.start_server( | |||
handle_echo, '127.0.0.1', 8888) | |||
|
|||
addr = server.sockets[0].getsockname() | |||
print(f'Serving on {addr}') | |||
addr = ', '.join(str(sock.getsockname()) for sock in server.sockets) |
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.
Why str()
here? For None
values? If so I'd prefer:
', '.join(sock.getsockname() for sock in server.sockets if sock.getsockname())
to avoid printing "None" but I don't like the double call to getsockname, maybe:
', '.join(name for sock in server.sockets if (name := sock.getsockname()))
?
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.
TypeError: sequence item 0: expected str instance, tuple found
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.
The name depends on the address family. It could also be bytes. https://bugs.python.org/issue17683
str() seems safest.
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.
Missed this, OK for str.
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.
The name depends on the address family. It could also be bytes. https://bugs.python.org/issue17683
It's a tuple.
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.
The variable name should be plural. Maybe addrs
?
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.
LGTM but please rename the variable to addrs, as @ericvsmith suggested.
Thanks @OlafvdSpek for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9. |
Thanks @OlafvdSpek for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10. |
…ythonGH-28828) (cherry picked from commit 659812b) Co-authored-by: Olaf van der Spek <[email protected]>
GH-28879 is a backport of this pull request to the 3.9 branch. |
…ythonGH-28828) (cherry picked from commit 659812b) Co-authored-by: Olaf van der Spek <[email protected]>
GH-28880 is a backport of this pull request to the 3.10 branch. |
…H-28828) (cherry picked from commit 659812b) Co-authored-by: Olaf van der Spek <[email protected]>
…H-28828) (cherry picked from commit 659812b) Co-authored-by: Olaf van der Spek <[email protected]>
https://bugs.python.org/issue45351