From b9537e71509ec664b4c12001bb97d6fddb6a8e8b Mon Sep 17 00:00:00 2001 From: Carel Combrink Date: Mon, 10 Nov 2025 14:18:53 +0200 Subject: [PATCH 1/3] THRIFT-5885 Fix enum generation - Also an issue for latest builds on later windows not only the appveyor builds like originally thoughts - Used the code as suggested from the ticket as-is without too much understanding --- compiler/cpp/src/thrift/generate/t_py_generator.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_py_generator.cc b/compiler/cpp/src/thrift/generate/t_py_generator.cc index b86f870dd94..c88c71175f4 100644 --- a/compiler/cpp/src/thrift/generate/t_py_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_py_generator.cc @@ -984,8 +984,8 @@ void t_py_generator::generate_py_struct_definition(ostream& out, t_type* type = (*m_iter)->get_type(); if (type->is_enum()) { out << indent() << "if name == \"" << (*m_iter)->get_name() << "\":" << '\n' - << indent() << indent_str() << "super().__setattr__(name, value if hasattr(value, 'value') else " - << type_name(type) << ".__members__.get(value))" << '\n' + << indent() << indent_str() << "super().__setattr__(name, value if hasattr(value, 'value') or value is None else " + << type_name(type) << "(value))" << '\n' << indent() << indent_str() << "return" << '\n'; } } From 6e8a2227daf38bfe9d9ee39c2d1eaa2e5355ecc0 Mon Sep 17 00:00:00 2001 From: Carel Combrink Date: Mon, 10 Nov 2025 14:27:01 +0200 Subject: [PATCH 2/3] Try to re-enable the enum tests --- test/py/RunClientServer.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/py/RunClientServer.py b/test/py/RunClientServer.py index db0814f0724..bbfdca2efcf 100755 --- a/test/py/RunClientServer.py +++ b/test/py/RunClientServer.py @@ -289,10 +289,6 @@ def main(): # Skip type hints tests -> See THRIFT-5885 (it might be related) print('Skipping \'type_hints\' tests') continue - if gp_dir == 'enum': - # Skip enum tests -> See THRIFT-5885 - print('Skipping \'enum\' tests') - continue generated_dirs.append('gen-py-%s' % (gp_dir)) # commandline permits a single class name to be specified to override SERVERS=[...] From eea27ebdde6170db36e68c848754dbaf856edd0d Mon Sep 17 00:00:00 2001 From: Carel Combrink Date: Tue, 11 Nov 2025 14:21:23 +0000 Subject: [PATCH 3/3] Put back type_hints for python after 3.7 --- test/py/RunClientServer.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/py/RunClientServer.py b/test/py/RunClientServer.py index bbfdca2efcf..278f06cc846 100755 --- a/test/py/RunClientServer.py +++ b/test/py/RunClientServer.py @@ -285,9 +285,8 @@ def main(): generated_dirs = [] for gp_dir in options.genpydirs.split(','): - if gp_dir == 'type_hints': - # Skip type hints tests -> See THRIFT-5885 (it might be related) - print('Skipping \'type_hints\' tests') + if gp_dir == 'type_hints' and (sys.version_info < (3,7)): + print('Skipping \'type_hints\' test since python 3.7 or later is required') continue generated_dirs.append('gen-py-%s' % (gp_dir))