summaryrefslogtreecommitdiff
path: root/Objects/funcobject.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-16 18:34:24 +0100
committerGitHub <noreply@github.com>2022-11-16 18:34:24 +0100
commit8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b (patch)
tree510409237622aa30dfc6833602bdde97c578f2bb /Objects/funcobject.c
parent19c1462e8dca3319c8290e2edcce482bd18cb018 (diff)
downloadcpython-git-8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b.tar.gz
gh-99300: Replace Py_INCREF() with Py_NewRef() (#99530)
Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef() and Py_XNewRef().
Diffstat (limited to 'Objects/funcobject.c')
-rw-r--r--Objects/funcobject.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index 80117bfb20..d60e4eb848 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -47,9 +47,8 @@ PyFunction_NewWithQualName(PyObject *code, PyObject *globals, PyObject *qualname
PyCodeObject *code_obj = (PyCodeObject *)Py_NewRef(code);
- PyObject *name = code_obj->co_name;
- assert(name != NULL);
- Py_INCREF(name);
+ assert(code_obj->co_name != NULL);
+ PyObject *name = Py_NewRef(code_obj->co_name);
if (!qualname) {
qualname = code_obj->co_qualname;
@@ -525,10 +524,7 @@ func_get_annotations(PyFunctionObject *op, void *Py_UNUSED(ignored))
return NULL;
}
PyObject *d = func_get_annotation_dict(op);
- if (d) {
- Py_INCREF(d);
- }
- return d;
+ return Py_XNewRef(d);
}
static int