Browse Source

Fixed Python C++ extension for Python 3.8.

Python 3.8 changed the meaning and type of the tp_print slot.
Joshua Haberman 4 years ago
parent
commit
c2c13a558a

+ 1 - 1
python/google/protobuf/pyext/repeated_composite_container.cc

@@ -567,7 +567,7 @@ PyTypeObject RepeatedCompositeContainer_Type = {
     sizeof(RepeatedCompositeContainer),         // tp_basicsize
     sizeof(RepeatedCompositeContainer),         // tp_basicsize
     0,                                          //  tp_itemsize
     0,                                          //  tp_itemsize
     repeated_composite_container::Dealloc,      //  tp_dealloc
     repeated_composite_container::Dealloc,      //  tp_dealloc
-    nullptr,                                    //  tp_print
+    0,                                          //  tp_print, in Python >=3.8: Py_ssize_t tp_vectorcall_offset
     nullptr,                                    //  tp_getattr
     nullptr,                                    //  tp_getattr
     nullptr,                                    //  tp_setattr
     nullptr,                                    //  tp_setattr
     nullptr,                                    //  tp_compare
     nullptr,                                    //  tp_compare

+ 1 - 1
python/google/protobuf/pyext/repeated_scalar_container.cc

@@ -753,7 +753,7 @@ PyTypeObject RepeatedScalarContainer_Type = {
     sizeof(RepeatedScalarContainer),         // tp_basicsize
     sizeof(RepeatedScalarContainer),         // tp_basicsize
     0,                                       //  tp_itemsize
     0,                                       //  tp_itemsize
     repeated_scalar_container::Dealloc,      //  tp_dealloc
     repeated_scalar_container::Dealloc,      //  tp_dealloc
-    nullptr,                                 //  tp_print
+    0,                                       //  tp_print, in Python >=3.8: Py_ssize_t tp_vectorcall_offset
     nullptr,                                 //  tp_getattr
     nullptr,                                 //  tp_getattr
     nullptr,                                 //  tp_setattr
     nullptr,                                 //  tp_setattr
     nullptr,                                 //  tp_compare
     nullptr,                                 //  tp_compare