File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -10,11 +10,11 @@ static inline PyObject* Py_NewRef(PyObject* ob) {
1010#if PY_MAJOR_VERSION != 3
1111#error "Python 3 is needed to build"
1212#endif
13- #if PY_MINOR_VERSION = = 11
13+ #if PY_MINOR_VERSION > = 11
1414#define GET_CODE (frame ) PyFrame_GetCode(frame);
1515#define GET_LOCALS (frame ) PyFrame_GetLocals(frame);
1616#else
17- #define GET_CODE (frame ) frame->f_code;
17+ #define GET_CODE (frame ) Py_NewRef( frame->f_code) ;
1818#define GET_LOCALS (frame ) Py_NewRef(frame->f_locals);
1919#endif
2020#include <signal.h>
@@ -124,15 +124,16 @@ static PyObject* handle(PyObject* self, PyObject* args) {
124124
125125 if (frame ) {
126126 code = GET_CODE (frame );
127- Py_INCREF (code );
128- name = code -> co_name ;
127+ name = Py_NewRef (code -> co_name );
129128 } else {
130129 name = PyObject_GetAttrString (
131130 func ,
132131 "__name__"
133132 );
134133 }
135134
135+ Py_DECREF (frame );
136+
136137 // this is basically a copy of PyFrame_GetCode, which is only available on 3.9+
137138 PyErr_Format (
138139 PyExc_RuntimeError ,
You can’t perform that action at this time.
0 commit comments