diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2020-05-17 06:32:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-17 06:32:46 (GMT) |
commit | 9a45bfe6f4aedd2a9d94cb12aa276057b15d8b63 (patch) | |
tree | de9431975c00c9fc34a3b7ba72bfc3bf20c86217 | |
parent | d7184d3dbd249444ec3961641dc08a9ad3c1ac34 (diff) | |
download | cpython-9a45bfe6f4aedd2a9d94cb12aa276057b15d8b63.zip cpython-9a45bfe6f4aedd2a9d94cb12aa276057b15d8b63.tar.gz cpython-9a45bfe6f4aedd2a9d94cb12aa276057b15d8b63.tar.bz2 |
bpo-35569: Expose RFC 3542 IPv6 socket options on macOS (GH-19526)
-rwxr-xr-x | Lib/test/test_socket.py | 31 | ||||
-rw-r--r-- | Misc/NEWS.d/next/macOS/2020-04-15-00-02-47.bpo-35569.02_1MV.rst | 1 | ||||
-rw-r--r-- | setup.py | 8 |
3 files changed, 38 insertions, 2 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 4a436cf..aefba4f 100755 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -959,6 +959,37 @@ class GeneralModuleTests(unittest.TestCase): socket.IPPROTO_L2TP socket.IPPROTO_SCTP + @unittest.skipUnless(sys.platform == 'darwin', 'macOS specific test') + @unittest.skipUnless(socket_helper.IPV6_ENABLED, 'IPv6 required for this test') + def test3542SocketOptions(self): + # Ref. issue #35569 and https://tools.ietf.org/html/rfc3542 + opts = { + 'IPV6_CHECKSUM', + 'IPV6_DONTFRAG', + 'IPV6_DSTOPTS', + 'IPV6_HOPLIMIT', + 'IPV6_HOPOPTS', + 'IPV6_NEXTHOP', + 'IPV6_PATHMTU', + 'IPV6_PKTINFO', + 'IPV6_RECVDSTOPTS', + 'IPV6_RECVHOPLIMIT', + 'IPV6_RECVHOPOPTS', + 'IPV6_RECVPATHMTU', + 'IPV6_RECVPKTINFO', + 'IPV6_RECVRTHDR', + 'IPV6_RECVTCLASS', + 'IPV6_RTHDR', + 'IPV6_RTHDRDSTOPTS', + 'IPV6_RTHDR_TYPE_0', + 'IPV6_TCLASS', + 'IPV6_USE_MIN_MTU', + } + for opt in opts: + self.assertTrue( + hasattr(socket, opt), f"Missing RFC3542 socket option '{opt}'" + ) + def testHostnameRes(self): # Testing hostname resolution mechanisms hostname = socket.gethostname() diff --git a/Misc/NEWS.d/next/macOS/2020-04-15-00-02-47.bpo-35569.02_1MV.rst b/Misc/NEWS.d/next/macOS/2020-04-15-00-02-47.bpo-35569.02_1MV.rst new file mode 100644 index 0000000..ed48efd --- /dev/null +++ b/Misc/NEWS.d/next/macOS/2020-04-15-00-02-47.bpo-35569.02_1MV.rst @@ -0,0 +1 @@ +Expose RFC 3542 IPv6 socket options. @@ -1116,8 +1116,12 @@ class PyBuildExt(build_ext): def detect_socket(self): # socket(2) if not VXWORKS: - self.add(Extension('_socket', ['socketmodule.c'], - depends=['socketmodule.h'])) + kwargs = {'depends': ['socketmodule.h']} + if MACOS: + # Issue #35569: Expose RFC 3542 socket options. + kwargs['extra_compile_args'] = ['-D__APPLE_USE_RFC_3542'] + + self.add(Extension('_socket', ['socketmodule.c'], **kwargs)) elif self.compiler.find_library_file(self.lib_dirs, 'net'): libs = ['net'] self.add(Extension('_socket', ['socketmodule.c'], |