Skip to content

gh-155336: Preserve resolver errors from gethostby*_r() - #155337

Open
kulikjak wants to merge 3 commits into
python:mainfrom
kulikjak:fix-gethostbyxxxx-error-handling
Open

gh-155336: Preserve resolver errors from gethostby*_r()#155337
kulikjak wants to merge 3 commits into
python:mainfrom
kulikjak:fix-gethostbyxxxx-error-handling

Conversation

@kulikjak

@kulikjakkulikjak commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Fixesgh-155336.

This change captures the error from all variants into h_error (depending on the way it should be captured) and later uses it in gethost_common().

Tested on Oracle Solaris - I am now getting a correct error:

>>> import socket
>>> socket.gethostbyaddr('1.2.3.4')
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
socket.gethostbyaddr('1.2.3.4')
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^socket.herror: [Errno 1] Unknown host

@serhiy-storchakaserhiy-storchaka 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.

LGTM, but please add a NEWS entry.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviewneeds backport to 3.13bugs and security fixesneeds backport to 3.14bugs and security fixesneeds backport to 3.15pre-release feature fixes, bugs and security fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

socket.gethostbyname_ex() and socket.gethostbyaddr() can report incorrect resolver errors

2 participants

@kulikjak@serhiy-storchaka