File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -594,9 +594,15 @@ def bind_port(sock, host=HOST):
594594 raise TestFailed ("tests should never set the SO_REUSEADDR " \
595595 "socket option on TCP/IP sockets!" )
596596 if hasattr (socket , 'SO_REUSEPORT' ):
597- if sock .getsockopt (socket .SOL_SOCKET , socket .SO_REUSEPORT ) == 1 :
598- raise TestFailed ("tests should never set the SO_REUSEPORT " \
599- "socket option on TCP/IP sockets!" )
597+ try :
598+ if sock .getsockopt (socket .SOL_SOCKET , socket .SO_REUSEPORT ) == 1 :
599+ raise TestFailed ("tests should never set the SO_REUSEPORT " \
600+ "socket option on TCP/IP sockets!" )
601+ except OSError :
602+ # Python's socket module was compiled using modern headers
603+ # thus defining SO_REUSEPORT but this process is running
604+ # under an older kernel that does not support SO_REUSEPORT.
605+ pass
600606 if hasattr (socket , 'SO_EXCLUSIVEADDRUSE' ):
601607 sock .setsockopt (socket .SOL_SOCKET , socket .SO_EXCLUSIVEADDRUSE , 1 )
602608
Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ Core and Builtins
5050Library
5151-------
5252
53+ - Fix test.support.bind_port() to not cause an error when Python was compiled
54+ on a system with SO_REUSEPORT defined in the headers but run on a system
55+ with an OS kernel that does not support that reasonably new socket option.
56+
5357- Fix compilation error under gcc of the ctypes module bundled libffi for arm.
5458
5559- Issue #19448: Add private API to SSL module to lookup ASN.1 objects by OID,
You can’t perform that action at this time.
0 commit comments