11
11
#include "python/descriptor.h"
12
12
#include "python/extension_dict.h"
13
13
#include "python/map.h"
14
+ #include "python/protobuf.h"
14
15
#include "python/repeated.h"
15
16
#include "upb/base/string_view.h"
16
17
#include "upb/message/compare.h"
@@ -45,12 +46,6 @@ typedef struct {
45
46
size_t type_basicsize ; // sizeof(PyHeapTypeObject)
46
47
traverseproc type_traverse ; // PyTypeObject.tp_traverse
47
48
inquiry type_clear ; // PyTypeObject.tp_clear
48
-
49
- // While we can refer to PY_VERSION_HEX in the limited API, this will give us
50
- // the version of Python we were compiled against, which may be different
51
- // than the version we are dynamically linked against. Here we want the
52
- // version that is actually running in this process.
53
- long python_version_hex ; // PY_VERSION_HEX
54
49
} PyUpb_CPythonBits ;
55
50
56
51
// A global containing the values for this process.
@@ -144,7 +139,6 @@ static bool PyUpb_CPythonBits_Init(PyUpb_CPythonBits* bits) {
144
139
145
140
sys = PyImport_ImportModule ("sys" );
146
141
hex_version = PyObject_GetAttrString (sys , "hexversion" );
147
- bits -> python_version_hex = PyLong_AsLong (hex_version );
148
142
ret = true;
149
143
150
144
err :
@@ -836,18 +830,7 @@ static void PyUpb_Message_Dealloc(PyObject* _self) {
836
830
}
837
831
838
832
Py_DECREF (self -> arena );
839
-
840
- // We do not use PyUpb_Dealloc() here because Message is a base type and for
841
- // base types there is a bug we have to work around in this case (see below).
842
- PyTypeObject * tp = Py_TYPE (self );
843
- freefunc tp_free = PyType_GetSlot (tp , Py_tp_free );
844
- tp_free (self );
845
-
846
- if (cpython_bits .python_version_hex >= 0x03080000 ) {
847
- // Prior to Python 3.8 there is a bug where deallocating the type here would
848
- // lead to a double-decref: https://bugs.python.org/issue37879
849
- Py_DECREF (tp );
850
- }
833
+ PyUpb_Dealloc (self );
851
834
}
852
835
853
836
PyObject * PyUpb_Message_Get (upb_Message * u_msg , const upb_MessageDef * m ,
0 commit comments