diff options
author | Victor Stinner <vstinner@python.org> | 2022-11-14 12:44:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-14 12:44:56 (GMT) |
commit | c340cbb7f74bc99eaf72d6a4ef5b4d504d8519c8 (patch) | |
tree | 2fa984d78bf3aa7e8c713f33c7ffdd6ed5817eb4 /Modules/_tracemalloc.c | |
parent | 9a7e9f9921804f3f90151ca42703e612697dd430 (diff) | |
download | cpython-c340cbb7f74bc99eaf72d6a4ef5b4d504d8519c8.zip cpython-c340cbb7f74bc99eaf72d6a4ef5b4d504d8519c8.tar.gz cpython-c340cbb7f74bc99eaf72d6a4ef5b4d504d8519c8.tar.bz2 |
gh-99300: Use Py_NewRef() in Modules/ directory (#99468)
Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in test C files of the Modules/ directory.
Diffstat (limited to 'Modules/_tracemalloc.c')
-rw-r--r-- | Modules/_tracemalloc.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c index 44a1f7b..fe73d63 100644 --- a/Modules/_tracemalloc.c +++ b/Modules/_tracemalloc.c @@ -347,8 +347,8 @@ tracemalloc_get_frame(_PyInterpreterFrame *pyframe, frame_t *frame) else { /* tracemalloc_filenames is responsible to keep a reference to the filename */ - Py_INCREF(filename); - if (_Py_hashtable_set(tracemalloc_filenames, filename, NULL) < 0) { + if (_Py_hashtable_set(tracemalloc_filenames, Py_NewRef(filename), + NULL) < 0) { Py_DECREF(filename); #ifdef TRACE_DEBUG tracemalloc_error("failed to intern the filename"); @@ -1085,8 +1085,7 @@ frame_to_pyobject(frame_t *frame) if (frame_obj == NULL) return NULL; - Py_INCREF(frame->filename); - PyTuple_SET_ITEM(frame_obj, 0, frame->filename); + PyTuple_SET_ITEM(frame_obj, 0, Py_NewRef(frame->filename)); lineno_obj = PyLong_FromUnsignedLong(frame->lineno); if (lineno_obj == NULL) { @@ -1107,8 +1106,7 @@ traceback_to_pyobject(traceback_t *traceback, _Py_hashtable_t *intern_table) if (intern_table != NULL) { frames = _Py_hashtable_get(intern_table, (const void *)traceback); if (frames) { - Py_INCREF(frames); - return frames; + return Py_NewRef(frames); } } |