THRIFT-5899: Python tests fail for the Appveyor MSVC builds (#3229)
* Temporarily switch off shared build
- See THRIFT-5898
* Skip type_hints tests for python lower than 3.7
- PR#2929 called out that the changes breaks Python 3.5 since types came in in 3.6
- Python 3.6 errors out with 'from __future__ import annotations' since it looks like it was only added in 3.7
* More appveyer issues on Windows due to old python
* Remove enum tests for old python versions
- Getting `raise TApplicationException(TApplicationException.MISSING_RESULT, "testEnum failed: unknown result"` error
- PR#2825 state it is a breaking change, not sure why and for what version of Python
* Disable SSL tests for old Python
- Appveyor error: ` AttributeError: module 'ssl' has no attribute 'PROTOCOL_TLS_CLIENT'`
* Can't get the test to skip so revert the change that broke it
- See PR#3050
* THRIFT-5900: Pin the cross test stage to python 3.13
- See https://issues.apache.org/jira/browse/THRIFT-5900
diff --git a/lib/py/src/transport/TSSLSocket.py b/lib/py/src/transport/TSSLSocket.py
index d3263c6..dc6c1fb 100644
--- a/lib/py/src/transport/TSSLSocket.py
+++ b/lib/py/src/transport/TSSLSocket.py
@@ -47,8 +47,13 @@
# SSL 2.0 and 3.0 are disabled via ssl.OP_NO_SSLv2 and ssl.OP_NO_SSLv3.
# For python < 2.7.9, use TLS 1.0 since TLSv1_X nor OP_NO_SSLvX is
# unavailable.
- _default_protocol = ssl.PROTOCOL_TLS_CLIENT if _has_ssl_context else \
- ssl.PROTOCOL_TLSv1
+ # For python < 3.6, use SSLv23 since TLS is not available
+ if sys.version_info < (3, 6):
+ _default_protocol = ssl.PROTOCOL_SSLv23 if _has_ssl_context else \
+ ssl.PROTOCOL_TLSv1
+ else:
+ _default_protocol = ssl.PROTOCOL_TLS_CLIENT if _has_ssl_context else \
+ ssl.PROTOCOL_TLSv1
def _init_context(self, ssl_version):
if self._has_ssl_context:
diff --git a/lib/py/src/transport/TSocket.py b/lib/py/src/transport/TSocket.py
index 51ea7e3..327dae0 100644
--- a/lib/py/src/transport/TSocket.py
+++ b/lib/py/src/transport/TSocket.py
@@ -22,6 +22,7 @@
import os
import socket
import sys
+import platform
from .TTransport import TTransportBase, TTransportException, TServerTransportBase
@@ -234,7 +235,10 @@
self.handle = s = socket.socket(res[0], res[1])
if s.family is socket.AF_INET6:
- s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
+ if platform.system() == 'Windows' and sys.version_info < (3, 8):
+ logger.warning('Windows socket defaulting to IPv4 for Python < 3.8: See https://github.com/python/cpython/issues/73701')
+ else:
+ s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
if hasattr(s, 'settimeout'):
s.settimeout(None)