From a05cd6244da2c219ebc3c58a1e1889f8e5e9b5aa Mon Sep 17 00:00:00 2001 From: Alper Yoney Date: Tue, 10 Dec 2024 15:39:56 -0800 Subject: [PATCH] Fix for python < 3.10 Summary: Structural pattern matching and `Py_TPFLAGS_MAPPING` added in 3.10+ Reviewed By: createdbysk Differential Revision: D67044512 fbshipit-source-id: ac668360b161806ff49051e380b890fc84a47dad --- third-party/thrift/src/thrift/lib/python/types.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/third-party/thrift/src/thrift/lib/python/types.cpp b/third-party/thrift/src/thrift/lib/python/types.cpp index e56477a06f8b0a..8c18b8e2ba4fca 100644 --- a/third-party/thrift/src/thrift/lib/python/types.cpp +++ b/third-party/thrift/src/thrift/lib/python/types.cpp @@ -1705,11 +1705,15 @@ PyObject* getStandardMutableDefaultValuePtrForType( void tag_object_as_sequence(PyTypeObject* type_object) { DCHECK(PyType_Check(type_object)); +#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 10 type_object->tp_flags |= Py_TPFLAGS_SEQUENCE; +#endif } void tag_object_as_mapping(PyTypeObject* type_object) { DCHECK(PyType_Check(type_object)); +#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 10 type_object->tp_flags |= Py_TPFLAGS_MAPPING; +#endif } } // namespace apache::thrift::python