Skip to content

Commit e720e6f

Browse files
authored
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
1 parent e7ab34e commit e720e6f

File tree

5 files changed

+26
-5
lines changed

5 files changed

+26
-5
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ jobs:
638638

639639
- uses: actions/setup-python@v6
640640
with:
641-
python-version: "3.x"
641+
python-version: "3.13" # Pin to 3.13 for now -> see THRIFT-5900
642642

643643
- uses: actions/setup-java@v5
644644
with:

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ environment:
4040
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
4141
PLATFORM: x64
4242
CONFIGURATION: Release
43-
BUILD_SHARED_LIBS: ON
43+
BUILD_SHARED_LIBS: OFF
4444
BOOST_VERSION: 1.67.0
4545
LIBEVENT_VERSION: 2.1.8
4646
PYTHON_VERSION: 3.6

lib/py/src/transport/TSSLSocket.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,13 @@ class TSSLBase(object):
4747
# SSL 2.0 and 3.0 are disabled via ssl.OP_NO_SSLv2 and ssl.OP_NO_SSLv3.
4848
# For python < 2.7.9, use TLS 1.0 since TLSv1_X nor OP_NO_SSLvX is
4949
# unavailable.
50-
_default_protocol = ssl.PROTOCOL_TLS_CLIENT if _has_ssl_context else \
51-
ssl.PROTOCOL_TLSv1
50+
# For python < 3.6, use SSLv23 since TLS is not available
51+
if sys.version_info < (3, 6):
52+
_default_protocol = ssl.PROTOCOL_SSLv23 if _has_ssl_context else \
53+
ssl.PROTOCOL_TLSv1
54+
else:
55+
_default_protocol = ssl.PROTOCOL_TLS_CLIENT if _has_ssl_context else \
56+
ssl.PROTOCOL_TLSv1
5257

5358
def _init_context(self, ssl_version):
5459
if self._has_ssl_context:

lib/py/src/transport/TSocket.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import os
2323
import socket
2424
import sys
25+
import platform
2526

2627
from .TTransport import TTransportBase, TTransportException, TServerTransportBase
2728

@@ -234,7 +235,10 @@ def listen(self):
234235

235236
self.handle = s = socket.socket(res[0], res[1])
236237
if s.family is socket.AF_INET6:
237-
s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
238+
if platform.system() == 'Windows' and sys.version_info < (3, 8):
239+
logger.warning('Windows socket defaulting to IPv4 for Python < 3.8: See https://github.com/python/cpython/issues/73701')
240+
else:
241+
s.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
238242
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
239243
if hasattr(s, 'settimeout'):
240244
s.settimeout(None)

test/py/RunClientServer.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ def run(self, conf, test_count):
212212
# skip any servers that don't work with SSL
213213
if with_ssl and try_server in SKIP_SSL:
214214
return False
215+
if with_ssl and (sys.version_info < (3,7)):
216+
print('Skipping \'with_ssl\' test since python 3.7 or later is required')
217+
return False
215218
if self.verbose > 0:
216219
print('\nTest run #%d: (includes %s) Server=%s, Proto=%s, zlib=%s, SSL=%s'
217220
% (test_count, genpydir, try_server, try_proto, with_zlib, with_ssl))
@@ -243,6 +246,9 @@ def run_all_tests(self):
243246
# skip any servers that don't work with SSL
244247
if with_ssl and try_server in SKIP_SSL:
245248
continue
249+
if with_ssl and (sys.version_info < (3,7)):
250+
print('Skipping \'with_ssl\' test since python 3.7 or later is required')
251+
continue
246252
test_count += 1
247253
if self.verbose > 0:
248254
print('\nTest run #%d: (includes %s) Server=%s, Proto=%s, zlib=%s, SSL=%s'
@@ -277,6 +283,12 @@ def main():
277283

278284
generated_dirs = []
279285
for gp_dir in options.genpydirs.split(','):
286+
if gp_dir == 'type_hints' and (sys.version_info < (3,7)):
287+
print('Skipping \'type_hints\' test since python 3.7 or later is required')
288+
continue
289+
if gp_dir == 'enum' and (sys.version_info < (3,7)):
290+
print('Skipping \'enum\' test since python 3.7 or later is required')
291+
continue
280292
generated_dirs.append('gen-py-%s' % (gp_dir))
281293

282294
# commandline permits a single class name to be specified to override SERVERS=[...]

0 commit comments

Comments
 (0)