Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b24f481

Browse files
committed
Issue #20605: Make test_socket getaddrinfo OS X segfault test more robust.
1 parent ffadbb7 commit b24f481

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

Lib/test/test_socket.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,9 +1164,15 @@ def testGetaddrinfo(self):
11641164
# Issue #6697.
11651165
self.assertRaises(UnicodeEncodeError, socket.getaddrinfo, 'localhost', '\uD800')
11661166

1167-
# Issue 17269
1167+
# Issue 17269: test workaround for OS X platform bug segfault
11681168
if hasattr(socket, 'AI_NUMERICSERV'):
1169-
socket.getaddrinfo("localhost", None, 0, 0, 0, socket.AI_NUMERICSERV)
1169+
try:
1170+
# The arguments here are undefined and the call may succeed
1171+
# or fail. All we care here is that it doesn't segfault.
1172+
socket.getaddrinfo("localhost", None, 0, 0, 0,
1173+
socket.AI_NUMERICSERV)
1174+
except socket.gaierror:
1175+
pass
11701176

11711177
def test_getnameinfo(self):
11721178
# only IP addresses are allowed

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ Tests
116116

117117
- Issue #20474: Fix test_socket "unexpected success" failures on OS X 10.7+.
118118

119+
- Issue #20605: Make test_socket getaddrinfo OS X segfault test more robust.
120+
119121
Documentation
120122
-------------
121123

0 commit comments

Comments
 (0)