summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-04-28 23:28:13 (GMT)
committerGitHub <noreply@github.com>2020-04-28 23:28:13 (GMT)
commit8852ad4208e34825f74e24945edb5bcf055d94fe (patch)
tree157f239ba46634301e136f4662b1646f7258357e /Objects
parent5e8c691594d68925213d36296ce7c4b3e90bcb1d (diff)
downloadcpython-8852ad4208e34825f74e24945edb5bcf055d94fe.zip
cpython-8852ad4208e34825f74e24945edb5bcf055d94fe.tar.gz
cpython-8852ad4208e34825f74e24945edb5bcf055d94fe.tar.bz2
bpo-40429: PyFrame_GetCode() now returns a strong reference (GH-19773)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/frameobject.c1
-rw-r--r--Objects/typeobject.c4
2 files changed, 3 insertions, 2 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 6b3559e..533186b 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -1237,5 +1237,6 @@ PyFrame_GetCode(PyFrameObject *frame)
assert(frame != NULL);
PyCodeObject *code = frame->f_code;
assert(code != NULL);
+ Py_INCREF(code);
return code;
}
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index f65f053..8f9ab5c 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -8031,7 +8031,6 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
/* Call super(), without args -- fill in from __class__
and first local variable on the stack. */
PyFrameObject *f;
- PyCodeObject *co;
Py_ssize_t i, n;
f = PyThreadState_GetFrame(_PyThreadState_GET());
if (f == NULL) {
@@ -8039,7 +8038,8 @@ super_init(PyObject *self, PyObject *args, PyObject *kwds)
"super(): no current frame");
return -1;
}
- co = PyFrame_GetCode(f);
+ PyCodeObject *co = PyFrame_GetCode(f);
+ Py_DECREF(co); // use a borrowed reference
if (co->co_argcount == 0) {
PyErr_SetString(PyExc_RuntimeError,
"super(): no arguments");