Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 91c6d28

Browse files
committed
Use Py_NewRef/Py_XNewRef
1 parent f91dcbc commit 91c6d28

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

pythoncapi_compat.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,9 @@ _Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size)
100100
static inline PyCodeObject*
101101
PyFrame_GetCode(PyFrameObject *frame)
102102
{
103-
PyCodeObject *code;
104103
assert(frame != NULL);
105-
code = frame->f_code;
106-
assert(code != NULL);
107-
Py_INCREF(code);
108-
return code;
104+
assert(frame->f_code != NULL);
105+
return (PyCodeObject*)Py_NewRef(frame->f_code);
109106
}
110107
#endif
111108

@@ -123,11 +120,8 @@ _PyFrame_GetCodeBorrow(PyFrameObject *frame)
123120
static inline PyFrameObject*
124121
PyFrame_GetBack(PyFrameObject *frame)
125122
{
126-
PyFrameObject *back;
127123
assert(frame != NULL);
128-
back = frame->f_back;
129-
Py_XINCREF(back);
130-
return back;
124+
return (PyFrameObject*)Py_XNewRef(frame->f_back);
131125
}
132126
#endif
133127

0 commit comments

Comments
 (0)