aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Objects/classobject.c
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2024-02-12 07:53:52 +0300
committerDaniil Cherednik <dcherednik@ydb.tech>2024-02-14 14:26:16 +0000
commit31f2a419764a8ba77c2a970cfc80056c6cd06756 (patch)
treec1995d239eba8571cefc640f6648e1d5dd4ce9e2 /contrib/tools/python3/src/Objects/classobject.c
parentfe2ef02b38d9c85d80060963b265a1df9f38c3bb (diff)
downloadydb-31f2a419764a8ba77c2a970cfc80056c6cd06756.tar.gz
Update Python from 3.11.8 to 3.12.2
Diffstat (limited to 'contrib/tools/python3/src/Objects/classobject.c')
-rw-r--r--contrib/tools/python3/src/Objects/classobject.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/contrib/tools/python3/src/Objects/classobject.c b/contrib/tools/python3/src/Objects/classobject.c
index b9708ba0e4..12dc276f28 100644
--- a/contrib/tools/python3/src/Objects/classobject.c
+++ b/contrib/tools/python3/src/Objects/classobject.c
@@ -48,6 +48,7 @@ method_vectorcall(PyObject *method, PyObject *const *args,
PyObject *self = PyMethod_GET_SELF(method);
PyObject *func = PyMethod_GET_FUNCTION(method);
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
+ assert(nargs == 0 || args[nargs-1]);
PyObject *result;
if (nargsf & PY_VECTORCALL_ARGUMENTS_OFFSET) {
@@ -56,6 +57,7 @@ method_vectorcall(PyObject *method, PyObject *const *args,
nargs += 1;
PyObject *tmp = newargs[0];
newargs[0] = self;
+ assert(newargs[nargs-1]);
result = _PyObject_VectorcallTstate(tstate, func, newargs,
nargs, kwnames);
newargs[0] = tmp;
@@ -113,10 +115,8 @@ PyMethod_New(PyObject *func, PyObject *self)
return NULL;
}
im->im_weakreflist = NULL;
- Py_INCREF(func);
- im->im_func = func;
- Py_INCREF(self);
- im->im_self = self;
+ im->im_func = Py_NewRef(func);
+ im->im_self = Py_NewRef(self);
im->vectorcall = method_vectorcall;
_PyObject_GC_TRACK(im);
return (PyObject *)im;
@@ -183,7 +183,7 @@ method_getattro(PyObject *obj, PyObject *name)
PyObject *descr = NULL;
{
- if (tp->tp_dict == NULL) {
+ if (!_PyType_IsReady(tp)) {
if (PyType_Ready(tp) < 0)
return NULL;
}
@@ -195,8 +195,7 @@ method_getattro(PyObject *obj, PyObject *name)
if (f != NULL)
return f(descr, obj, (PyObject *)Py_TYPE(obj));
else {
- Py_INCREF(descr);
- return descr;
+ return Py_NewRef(descr);
}
}
@@ -267,8 +266,7 @@ method_richcompare(PyObject *self, PyObject *other, int op)
res = eq ? Py_True : Py_False;
else
res = eq ? Py_False : Py_True;
- Py_INCREF(res);
- return res;
+ return Py_NewRef(res);
}
static PyObject *
@@ -287,8 +285,7 @@ method_repr(PyMethodObject *a)
}
if (funcname != NULL && !PyUnicode_Check(funcname)) {
- Py_DECREF(funcname);
- funcname = NULL;
+ Py_SETREF(funcname, NULL);
}
/* XXX Shouldn't use repr()/%R here! */
@@ -359,8 +356,7 @@ PyInstanceMethod_New(PyObject *func) {
method = PyObject_GC_New(PyInstanceMethodObject,
&PyInstanceMethod_Type);
if (method == NULL) return NULL;
- Py_INCREF(func);
- method->func = func;
+ method->func = Py_NewRef(func);
_PyObject_GC_TRACK(method);
return (PyObject *)method;
}
@@ -401,7 +397,7 @@ instancemethod_getattro(PyObject *self, PyObject *name)
PyTypeObject *tp = Py_TYPE(self);
PyObject *descr = NULL;
- if (tp->tp_dict == NULL) {
+ if (!_PyType_IsReady(tp)) {
if (PyType_Ready(tp) < 0)
return NULL;
}
@@ -412,8 +408,7 @@ instancemethod_getattro(PyObject *self, PyObject *name)
if (f != NULL)
return f(descr, self, (PyObject *)Py_TYPE(self));
else {
- Py_INCREF(descr);
- return descr;
+ return Py_NewRef(descr);
}
}
@@ -443,8 +438,7 @@ static PyObject *
instancemethod_descr_get(PyObject *descr, PyObject *obj, PyObject *type) {
PyObject *func = PyInstanceMethod_GET_FUNCTION(descr);
if (obj == NULL) {
- Py_INCREF(func);
- return func;
+ return Py_NewRef(func);
}
else
return PyMethod_New(func, obj);
@@ -472,8 +466,7 @@ instancemethod_richcompare(PyObject *self, PyObject *other, int op)
res = eq ? Py_True : Py_False;
else
res = eq ? Py_False : Py_True;
- Py_INCREF(res);
- return res;
+ return Py_NewRef(res);
}
static PyObject *
@@ -492,8 +485,7 @@ instancemethod_repr(PyObject *self)
return NULL;
}
if (funcname != NULL && !PyUnicode_Check(funcname)) {
- Py_DECREF(funcname);
- funcname = NULL;
+ Py_SETREF(funcname, NULL);
}
result = PyUnicode_FromFormat("<instancemethod %V at %p>",