Commits

Brian Kearns committed 7f52000

work around crash in getaddrinfo on osx (cpython issue17269)

Comments (0)

Files changed (2)

rpython/rlib/rsocket.py

                 address_to_fill=None):
     # port_or_service is a string, not an int (but try str(port_number)).
     assert port_or_service is None or isinstance(port_or_service, str)
+    if _c._MACOSX:
+        if port_or_service is None or port_or_service == '0':
+            port_or_service = '00'
     hints = lltype.malloc(_c.addrinfo, flavor='raw', zero=True)
     rffi.setintfield(hints, 'c_ai_family',   family)
     rffi.setintfield(hints, 'c_ai_socktype', socktype)

rpython/rlib/test/test_rsocket.py

             found = True
     assert found, lst
 
+def test_getaddrinfo_osx_crash():
+    # see CPython issue17269
+    for port in [None, '0', '00']:
+        getaddrinfo('localhost', port, 0, 0, 0, AI_NUMERICSERV)
+
 def test_connect_ex():
     s = RSocket()
     err = s.connect_ex(INETAddress('0.0.0.0', 0))   # should not work