Skip to content

Commit 3f59723

Browse files
committed
GR-9140: revert import socket patch
1 parent bba6f05 commit 3f59723

File tree

4 files changed

+23
-31
lines changed

4 files changed

+23
-31
lines changed

graalpython/lib-graalpython/_socket.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@
4646
SOCK_RAW = 3
4747
SOCK_RDM = 4
4848
SOCK_SEQPACKET = 5
49+
50+
has_ipv6 = False #: TODO implement me

graalpython/lib-python/3/logging/handlers.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@
2222
2323
To use, simply 'import logging.handlers' and log away!
2424
"""
25-
# TODO: Truffle reenable me once socket is supported (GR-9140)
26-
# import logging, socket, os, pickle, struct, time, re
27-
import logging, os, pickle, struct, time, re
25+
import logging, socket, os, pickle, struct, time, re
2826
from stat import ST_DEV, ST_INO, ST_MTIME
2927
# TODO: Truffle reenable me once queue and threading is supported (GR-9144)
3028
# import queue

graalpython/lib-python/3/platform.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@
113113
__version__ = '1.0.8'
114114

115115
import collections
116-
# TODO: Truffle reenable me once subprocess is supported (GR-9141)
117-
# import sys, os, re, subprocess
118-
import sys, os, re
116+
import sys, os, re, subprocess
119117

120118
import warnings
121119

graalpython/lib-python/3/test/support/__init__.py

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
import platform
2020
import re
2121
import shutil
22-
# TODO: Truffle reenable me once supported (GR-9140)
23-
# import socket
22+
import socket
2423
import stat
2524
import struct
26-
# TODO: Truffle reenable me once supported (GR-9141)
27-
# import subprocess
25+
import subprocess
2826
import sys
2927
import sysconfig
3028
import tempfile
@@ -628,9 +626,7 @@ def wrapper(*args, **kw):
628626
HOSTv6 = "::1"
629627

630628

631-
# TODO: revert me once socket is implemented (GR-9140)
632-
# def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
633-
def find_unused_port(family, socktype):
629+
def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
634630
"""Returns an unused port that should be suitable for binding. This is
635631
achieved by creating a temporary socket with the same family and type as
636632
the 'sock' parameter (default is AF_INET, SOCK_STREAM), and binding it to
@@ -738,24 +734,22 @@ def bind_unix_socket(sock, addr):
738734
sock.close()
739735
raise unittest.SkipTest('cannot bind AF_UNIX sockets')
740736

741-
# TODO: reenable me once socket is implemented (GR-9140)
742-
# def _is_ipv6_enabled():
743-
# """Check whether IPv6 is enabled on this host."""
744-
# if socket.has_ipv6:
745-
# sock = None
746-
# try:
747-
# sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
748-
# sock.bind((HOSTv6, 0))
749-
# return True
750-
# except OSError:
751-
# pass
752-
# finally:
753-
# if sock:
754-
# sock.close()
755-
# return False
756-
#
757-
# IPV6_ENABLED = _is_ipv6_enabled()
758-
IPV6_ENABLED = False
737+
def _is_ipv6_enabled():
738+
"""Check whether IPv6 is enabled on this host."""
739+
if socket.has_ipv6:
740+
sock = None
741+
try:
742+
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
743+
sock.bind((HOSTv6, 0))
744+
return True
745+
except OSError:
746+
pass
747+
finally:
748+
if sock:
749+
sock.close()
750+
return False
751+
752+
IPV6_ENABLED = _is_ipv6_enabled()
759753

760754
def system_must_validate_cert(f):
761755
"""Skip the test on TLS certificate validation failures."""

0 commit comments

Comments
 (0)