gh-93251: Decode localized socket error messages from the locale enco… · python/cpython@5afbb60 · GitHub
Skip to content

Commit 5afbb60

Browse files
gh-93251: Decode localized socket error messages from the locale encoding (GH-154683)
The gai_strerror() and hstrerror() messages were decoded as UTF-8, so gaierror and herror could be replaced with UnicodeDecodeError if the message is localized and the locale encoding is not UTF-8. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 306a35c commit 5afbb60

3 files changed

Lines changed: 33 additions & 2 deletions

File tree

Lib/test/test_socket.py

Lines changed: 17 additions & 0 deletions
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fix :exc:`UnicodeDecodeError` in :mod:`socket` functions
2+
(such as :func:`~socket.getaddrinfo` and :func:`~socket.gethostbyaddr`)
3+
when the localized error message of the C library is not UTF-8:
4+
decode it from the locale encoding.

Modules/socketmodule.c

Lines changed: 12 additions & 2 deletions

0 commit comments

Comments
 (0)