Skip to content

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

Merged
merged 3 commits into from
Oct 11, 2021
Merged

bpo-45351: Print all addresses #28828

merged 3 commits into from
Oct 11, 2021

Conversation

OlafvdSpek
Copy link
Contributor

@OlafvdSpek OlafvdSpek commented Oct 9, 2021

@the-knights-who-say-ni
Copy link

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 Missing

Our records indicate the following people have not signed the CLA:

@OlafvdSpek

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
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

@bedevere-bot bedevere-bot added the docs Documentation in the Doc dir label Oct 9, 2021
@@ -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)
Copy link
Member

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()))

?

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Member

@vstinner vstinner left a 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.

@vstinner vstinner merged commit 659812b into python:main Oct 11, 2021
@vstinner vstinner added needs backport to 3.9 only security fixes needs backport to 3.10 only security fixes labels Oct 11, 2021
@miss-islington
Copy link
Contributor

Thanks @OlafvdSpek for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Thanks @OlafvdSpek for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 11, 2021
@bedevere-bot
Copy link

GH-28879 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Oct 11, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 11, 2021
@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Oct 11, 2021
@bedevere-bot
Copy link

GH-28880 is a backport of this pull request to the 3.10 branch.

@OlafvdSpek OlafvdSpek deleted the patch-1 branch October 11, 2021 19:05
miss-islington added a commit that referenced this pull request Oct 11, 2021
miss-islington added a commit that referenced this pull request Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants