wait-send-in-upstream-fix-pydebug.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. diff --git a/python/google/protobuf/pyext/descriptor.cc b/python/google/protobuf/pyext/descriptor.cc
  2. index de9a248..8efe348 100644
  3. --- a/python/google/protobuf/pyext/descriptor.cc
  4. +++ b/python/google/protobuf/pyext/descriptor.cc
  5. @@ -443,6 +443,9 @@ PyObject* NewInternedDescriptor(PyTypeObject* type,
  6. static void Dealloc(PyObject* pself) {
  7. PyBaseDescriptor* self = reinterpret_cast<PyBaseDescriptor*>(pself);
  8. + if (PyObject_GC_IsTracked(pself)) {
  9. + PyObject_GC_UnTrack(pself);
  10. + }
  11. // Remove from interned dictionary
  12. interned_descriptors->erase(self->descriptor);
  13. Py_CLEAR(self->pool);
  14. diff --git a/python/google/protobuf/pyext/descriptor_pool.cc b/python/google/protobuf/pyext/descriptor_pool.cc
  15. index 0dd57b2..bfbbe4a 100644
  16. --- a/python/google/protobuf/pyext/descriptor_pool.cc
  17. +++ b/python/google/protobuf/pyext/descriptor_pool.cc
  18. @@ -212,6 +212,9 @@ static PyObject* New(PyTypeObject* type,
  19. static void Dealloc(PyObject* pself) {
  20. PyDescriptorPool* self = reinterpret_cast<PyDescriptorPool*>(pself);
  21. + if (PyObject_GC_IsTracked(pself)) {
  22. + PyObject_GC_UnTrack(pself);
  23. + }
  24. descriptor_pool_map->erase(self->pool);
  25. Py_CLEAR(self->py_message_factory);
  26. for (std::unordered_map<const void*, PyObject*>::iterator it =
  27. diff --git a/python/google/protobuf/pyext/map_container.cc b/python/google/protobuf/pyext/map_container.cc
  28. index 2d75c09..fe48b21 100644
  29. --- a/python/google/protobuf/pyext/map_container.cc
  30. +++ b/python/google/protobuf/pyext/map_container.cc
  31. @@ -515,6 +515,9 @@ PyObject* MapReflectionFriend::ScalarMapToStr(PyObject* _self) {
  32. static void ScalarMapDealloc(PyObject* _self) {
  33. MapContainer* self = GetMap(_self);
  34. + if (PyObject_GC_IsTracked(_self)) {
  35. + PyObject_GC_UnTrack(_self);
  36. + }
  37. self->RemoveFromParentCache();
  38. PyTypeObject *type = Py_TYPE(_self);
  39. type->tp_free(_self);
  40. @@ -728,6 +731,9 @@ PyObject* MessageMapGet(PyObject* self, PyObject* args, PyObject* kwargs) {
  41. static void MessageMapDealloc(PyObject* _self) {
  42. MessageMapContainer* self = GetMessageMap(_self);
  43. + if (PyObject_GC_IsTracked(_self)) {
  44. + PyObject_GC_UnTrack(_self);
  45. + }
  46. self->RemoveFromParentCache();
  47. Py_DECREF(self->message_class);
  48. PyTypeObject *type = Py_TYPE(_self);
  49. diff --git a/python/google/protobuf/pyext/message_factory.cc b/python/google/protobuf/pyext/message_factory.cc
  50. index 27aa5e4..060cc76 100644
  51. --- a/python/google/protobuf/pyext/message_factory.cc
  52. +++ b/python/google/protobuf/pyext/message_factory.cc
  53. @@ -104,6 +104,9 @@ PyObject* New(PyTypeObject* type, PyObject* args, PyObject* kwargs) {
  54. static void Dealloc(PyObject* pself) {
  55. PyMessageFactory* self = reinterpret_cast<PyMessageFactory*>(pself);
  56. + if (PyObject_GC_IsTracked(pself)) {
  57. + PyObject_GC_UnTrack(pself);
  58. + }
  59. typedef PyMessageFactory::ClassesByMessageMap::iterator iterator;
  60. for (iterator it = self->classes_by_descriptor->begin();
  61. it != self->classes_by_descriptor->end(); ++it) {