Skip to content

Commit fdefe67

Browse files
QuLogicedschofield
authored andcommitted
Fix exception handling in test.support.bind_port.
In Python 3.3, exceptions on sockets raise OSError, but since this code is a backport for 2.x, it needs to use the previous exception type, namely, socket.error.
1 parent cae65f4 commit fdefe67

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

future/backports/test/support.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ def bind_port(sock, host=HOST):
595595
if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT) == 1:
596596
raise TestFailed("tests should never set the SO_REUSEPORT " \
597597
"socket option on TCP/IP sockets!")
598-
except OSError:
598+
except socket.error:
599599
# Python's socket module was compiled using modern headers
600600
# thus defining SO_REUSEPORT but this process is running
601601
# under an older kernel that does not support SO_REUSEPORT.

0 commit comments

Comments
 (0)