File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -570,9 +570,15 @@ def bind_port(sock, host=HOST):
570570 raise TestFailed ("tests should never set the SO_REUSEADDR " \
571571 "socket option on TCP/IP sockets!" )
572572 if hasattr (socket , 'SO_REUSEPORT' ):
573- if sock .getsockopt (socket .SOL_SOCKET , socket .SO_REUSEPORT ) == 1 :
574- raise TestFailed ("tests should never set the SO_REUSEPORT " \
575- "socket option on TCP/IP sockets!" )
573+ try :
574+ if sock .getsockopt (socket .SOL_SOCKET , socket .SO_REUSEPORT ) == 1 :
575+ raise TestFailed ("tests should never set the SO_REUSEPORT " \
576+ "socket option on TCP/IP sockets!" )
577+ except OSError :
578+ # Python's socket module was compiled using modern headers
579+ # thus defining SO_REUSEPORT but this process is running
580+ # under an older kernel that does not support SO_REUSEPORT.
581+ pass
576582 if hasattr (socket , 'SO_EXCLUSIVEADDRUSE' ):
577583 sock .setsockopt (socket .SOL_SOCKET , socket .SO_EXCLUSIVEADDRUSE , 1 )
578584
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ Core and Builtins
1313Library
1414-------
1515
16+ - Fix test.support.bind_port() to not cause an error when Python was compiled
17+ on a system with SO_REUSEPORT defined in the headers but run on a system
18+ with an OS kernel that does not support that reasonably new socket option.
19+
1620- Fix compilation error under gcc of the ctypes module bundled libffi for arm.
1721
1822- Issue #19523: Closed FileHandler leak which occurred when delay was set.
You can’t perform that action at this time.
0 commit comments