diff options
author | Victor Stinner <vstinner@python.org> | 2022-11-10 11:23:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-10 11:23:36 +0100 |
commit | 231d83b72435d61e929d6d62f2be7305e7b5b62b (patch) | |
tree | 17768fa10f1ade6bae9022d26e1470fd0b931366 /Python/traceback.c | |
parent | d8f239d86eb70c31aa4c4ac46a1d0a27bdb14b20 (diff) | |
download | cpython-git-231d83b72435d61e929d6d62f2be7305e7b5b62b.tar.gz |
gh-99300: Use Py_NewRef() in Python/ directory (#99317)
Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in C files of the Python/ directory.
Update Parser/asdl_c.py to regenerate Python/Python-ast.c.
Diffstat (limited to 'Python/traceback.c')
-rw-r--r-- | Python/traceback.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/Python/traceback.c b/Python/traceback.c index de658b9103..2d9da0e692 100644 --- a/Python/traceback.c +++ b/Python/traceback.c @@ -52,10 +52,8 @@ tb_create_raw(PyTracebackObject *next, PyFrameObject *frame, int lasti, } tb = PyObject_GC_New(PyTracebackObject, &PyTraceBack_Type); if (tb != NULL) { - Py_XINCREF(next); - tb->tb_next = next; - Py_XINCREF(frame); - tb->tb_frame = frame; + tb->tb_next = (PyTracebackObject*)Py_XNewRef(next); + tb->tb_frame = (PyFrameObject*)Py_XNewRef(frame); tb->tb_lasti = lasti; tb->tb_lineno = lineno; PyObject_GC_Track(tb); @@ -106,8 +104,7 @@ tb_next_get(PyTracebackObject *self, void *Py_UNUSED(_)) if (!ret) { ret = Py_None; } - Py_INCREF(ret); - return ret; + return Py_NewRef(ret); } static int @@ -140,8 +137,7 @@ tb_next_set(PyTracebackObject *self, PyObject *new_next, void *Py_UNUSED(_)) } PyObject *old_next = (PyObject*)self->tb_next; - Py_XINCREF(new_next); - self->tb_next = (PyTracebackObject *)new_next; + self->tb_next = (PyTracebackObject *)Py_XNewRef(new_next); Py_XDECREF(old_next); return 0; @@ -522,8 +518,7 @@ display_source_line_with_margin(PyObject *f, PyObject *filename, int lineno, int } if (line) { - Py_INCREF(lineobj); - *line = lineobj; + *line = Py_NewRef(lineobj); } /* remove the indentation of the line */ |