gh-100218: correctly set `errno` when `socket.if_{nametoindex,indexto… · python/cpython@3ce2d57 · GitHub
Skip to content

Commit 3ce2d57

Browse files
authored
gh-100218: correctly set errno when socket.if_{nametoindex,indextoname} raise OSError (#140905)
Previously, socket.if_nametoindex() and socket.if_indextoname() could raise an `OSError` with a `None` errno. Now, the errno from libc is propagated.
1 parent 0c77e7c commit 3ce2d57

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

Lib/test/test_socket.py

Lines changed: 8 additions & 2 deletions
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Correctly set :attr:`~OSError.errno` when :func:`socket.if_nametoindex` or
2+
:func:`socket.if_indextoname` raise an :exc:`OSError`. Patch by Bénédikt
3+
Tran.

Modules/socketmodule.c

Lines changed: 3 additions & 2 deletions

0 commit comments

Comments
 (0)