Skip to content

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

Merged
serhiy-storchaka merged 4 commits into
python:mainfrom
kulikjak:fix-gethostbyxxxx-error-handling
Aug 10, 2026
Merged

gh-155336: Preserve resolver errors from gethostby*_r()#155337
serhiy-storchaka merged 4 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

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

@kulikjak

Copy link
Copy Markdown
Contributor Author

Ah, yes - I added a NEWS entry.

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

BTW, some of these issues I was able to reproduce on OpenIndiana.

@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) August 10, 2026 07:12
@serhiy-storchaka
serhiy-storchaka merged commit 5181a6e into python:main Aug 10, 2026
57 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @kulikjak for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Aug 10, 2026

Copy link
Copy Markdown

GH-155469 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Aug 10, 2026
@miss-islington-app

Copy link
Copy Markdown

Sorry, @kulikjak and @serhiy-storchaka, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 5181a6eca5de011cba15f8fc8fbffbeb3eec6db6 3.13

@bedevere-app

bedevere-app Bot commented Aug 10, 2026

Copy link
Copy Markdown

GH-155470 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 10, 2026
@bedevere-app

bedevere-app Bot commented Aug 10, 2026

Copy link
Copy Markdown

GH-155473 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

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