diff options
author | Victor Stinner <vstinner@python.org> | 2020-04-28 23:28:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-28 23:28:13 (GMT) |
commit | 8852ad4208e34825f74e24945edb5bcf055d94fe (patch) | |
tree | 157f239ba46634301e136f4662b1646f7258357e /Python/_warnings.c | |
parent | 5e8c691594d68925213d36296ce7c4b3e90bcb1d (diff) | |
download | cpython-8852ad4208e34825f74e24945edb5bcf055d94fe.zip cpython-8852ad4208e34825f74e24945edb5bcf055d94fe.tar.gz cpython-8852ad4208e34825f74e24945edb5bcf055d94fe.tar.bz2 |
bpo-40429: PyFrame_GetCode() now returns a strong reference (GH-19773)
Diffstat (limited to 'Python/_warnings.c')
-rw-r--r-- | Python/_warnings.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c index 7a620dc..7c15ce0 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -785,6 +785,8 @@ is_internal_frame(PyFrameObject *frame) PyCodeObject *code = PyFrame_GetCode(frame); PyObject *filename = code->co_filename; + Py_DECREF(code); + if (filename == NULL) { return 0; } @@ -850,7 +852,9 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno, } else { globals = f->f_globals; - *filename = PyFrame_GetCode(f)->co_filename; + PyCodeObject *code = PyFrame_GetCode(f); + *filename = code->co_filename; + Py_DECREF(code); Py_INCREF(*filename); *lineno = PyFrame_GetLineNumber(f); } |