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

@kulikjak kulikjak commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Fixes gh-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

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.

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

1 participant