summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-16 17:34:24 (GMT)
committerGitHub <noreply@github.com>2022-11-16 17:34:24 (GMT)
commit8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b (patch)
tree510409237622aa30dfc6833602bdde97c578f2bb /Python/compile.c
parent19c1462e8dca3319c8290e2edcce482bd18cb018 (diff)
downloadcpython-8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b.zip
cpython-8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b.tar.gz
cpython-8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b.tar.bz2
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 'Python/compile.c')
-rw-r--r--Python/compile.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/Python/compile.c b/Python/compile.c
index bd41ebc..9226bc2 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1459,8 +1459,7 @@ merge_consts_recursive(PyObject *const_cache, PyObject *o)
}
PyObject *u;
if (PyTuple_CheckExact(k)) {
- u = PyTuple_GET_ITEM(k, 1);
- Py_INCREF(u);
+ u = Py_NewRef(PyTuple_GET_ITEM(k, 1));
Py_DECREF(k);
}
else {
@@ -2732,8 +2731,7 @@ compiler_class(struct compiler *c, stmt_ty s)
{
location loc = LOCATION(firstlineno, firstlineno, 0, 0);
/* use the class name for name mangling */
- Py_INCREF(s->v.ClassDef.name);
- Py_XSETREF(c->u->u_private, s->v.ClassDef.name);
+ Py_XSETREF(c->u->u_private, Py_NewRef(s->v.ClassDef.name));
/* load (global) __name__ ... */
if (!compiler_nameop(c, loc, &_Py_ID(__name__), Load)) {
compiler_exit_scope(c);