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) {
10
10
#if PY_MAJOR_VERSION != 3
11
11
#error "Python 3 is needed to build"
12
12
#endif
13
- #if PY_MINOR_VERSION = = 11
13
+ #if PY_MINOR_VERSION > = 11
14
14
#define GET_CODE (frame ) PyFrame_GetCode(frame);
15
15
#define GET_LOCALS (frame ) PyFrame_GetLocals(frame);
16
16
#else
17
- #define GET_CODE (frame ) frame->f_code;
17
+ #define GET_CODE (frame ) Py_NewRef( frame->f_code) ;
18
18
#define GET_LOCALS (frame ) Py_NewRef(frame->f_locals);
19
19
#endif
20
20
#include <signal.h>
@@ -124,15 +124,16 @@ static PyObject* handle(PyObject* self, PyObject* args) {
124
124
125
125
if (frame ) {
126
126
code = GET_CODE (frame );
127
- Py_INCREF (code );
128
- name = code -> co_name ;
127
+ name = Py_NewRef (code -> co_name );
129
128
} else {
130
129
name = PyObject_GetAttrString (
131
130
func ,
132
131
"__name__"
133
132
);
134
133
}
135
134
135
+ Py_DECREF (frame );
136
+
136
137
// this is basically a copy of PyFrame_GetCode, which is only available on 3.9+
137
138
PyErr_Format (
138
139
PyExc_RuntimeError ,
You can’t perform that action at this time.
0 commit comments