Skip to content

Ensure socket.gethostbyname_ex only returns IPv4 addresses#4529

Merged
DimitrisJim merged 1 commit into
RustPython:mainfrom
haxelion:bugfix/fix_gethostbyname_ex
Feb 20, 2023
Merged

Ensure socket.gethostbyname_ex only returns IPv4 addresses#4529
DimitrisJim merged 1 commit into
RustPython:mainfrom
haxelion:bugfix/fix_gethostbyname_ex

Conversation

@haxelion
Copy link
Copy Markdown
Contributor

The gethostbyname_ex function of the socket module is only supposed to return IPv4 address as per the documentation: https://docs.python.org/3/library/socket.html#socket.gethostbyname_ex

This can also be seen in the CPython code: https://github.com/python/cpython/blob/c00faf79438cc7f0d98af2679c695f747e4369a3/Modules/socketmodule.c#L5882

This commit replace AF_UNSPEC with AF_INET so that only IPv4 are returned. This also fixes the test issue I had in PR #4526 .

I don't know if the test will pass on other platforms so I'm opening this PR to see the test results 🙂

Copy link
Copy Markdown
Member

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

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

seems to do the trick, thanks for looking into this!

@DimitrisJim DimitrisJim merged commit e0a2948 into RustPython:main Feb 20, 2023
@youknowone youknowone added the z-ls-2023 Tag to track Line OSS Sprint 2023 label Feb 20, 2023
@haxelion haxelion deleted the bugfix/fix_gethostbyname_ex branch February 21, 2023 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

z-ls-2023 Tag to track Line OSS Sprint 2023

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants