return NULL;
ro->index = n-1;
- Py_INCREF(seq);
- ro->seq = seq;
+ ro->seq = Py_NewRef(seq);
return (PyObject *)ro;
}
self->suppress_context = 0;
if (args) {
- self->args = args;
- Py_INCREF(args);
+ self->args = Py_NewRef(args);
return (PyObject *)self;
}
if (!_PyArg_NoKeywords(Py_TYPE(self)->tp_name, kwds))
return -1;
- Py_INCREF(args);
- Py_XSETREF(self->args, args);
-
+ Py_XSETREF(self->args, Py_NewRef(args));
return 0;
}
if (PyException_SetTraceback(self, tb))
return NULL;
- Py_INCREF(self);
- return self;
+ return Py_NewRef(self);
}
PyDoc_STRVAR(with_traceback_doc,
if (self->args == NULL) {
Py_RETURN_NONE;
}
- Py_INCREF(self->args);
- return self->args;
+ return Py_NewRef(self->args);
}
static int
if (self->traceback == NULL) {
Py_RETURN_NONE;
}
- Py_INCREF(self->traceback);
- return self->traceback;
+ return Py_NewRef(self->traceback);
}
static int
return -1;
}
- Py_INCREF(tb);
- Py_XSETREF(self->traceback, tb);
+ Py_XSETREF(self->traceback, Py_NewRef(tb));
return 0;
}
PyException_GetTraceback(PyObject *self)
{
PyBaseExceptionObject *base_self = _PyBaseExceptionObject_cast(self);
- Py_XINCREF(base_self->traceback);
- return base_self->traceback;
+ return Py_XNewRef(base_self->traceback);
}
PyException_GetCause(PyObject *self)
{
PyObject *cause = _PyBaseExceptionObject_cast(self)->cause;
- Py_XINCREF(cause);
- return cause;
+ return Py_XNewRef(cause);
}
/* Steals a reference to cause */
PyException_GetContext(PyObject *self)
{
PyObject *context = _PyBaseExceptionObject_cast(self)->context;
- Py_XINCREF(context);
- return context;
+ return Py_XNewRef(context);
}
/* Steals a reference to context */
value = PyTuple_GET_ITEM(args, 0);
else
value = Py_None;
- Py_INCREF(value);
- self->value = value;
+ self->value = Py_NewRef(value);
return 0;
}
if (size == 0)
return 0;
if (size == 1) {
- Py_INCREF(PyTuple_GET_ITEM(args, 0));
- Py_XSETREF(self->code, PyTuple_GET_ITEM(args, 0));
+ Py_XSETREF(self->code, Py_NewRef(PyTuple_GET_ITEM(args, 0)));
}
else { /* size > 1 */
- Py_INCREF(args);
- Py_XSETREF(self->code, args);
+ Py_XSETREF(self->code, Py_NewRef(args));
}
return 0;
}
}
Py_DECREF(empty_tuple);
- Py_XINCREF(name);
- Py_XSETREF(self->name, name);
-
- Py_XINCREF(path);
- Py_XSETREF(self->path, path);
-
- Py_XINCREF(name_from);
- Py_XSETREF(self->name_from, name_from);
+ Py_XSETREF(self->name, Py_XNewRef(name));
+ Py_XSETREF(self->path, Py_XNewRef(path));
+ Py_XSETREF(self->name_from, Py_XNewRef(name_from));
if (PyTuple_GET_SIZE(args) == 1) {
- msg = PyTuple_GET_ITEM(args, 0);
- Py_INCREF(msg);
+ msg = Py_NewRef(PyTuple_GET_ITEM(args, 0));
}
Py_XSETREF(self->msg, msg);
ImportError_str(PyImportErrorObject *self)
{
if (self->msg && PyUnicode_CheckExact(self->msg)) {
- Py_INCREF(self->msg);
- return self->msg;
+ return Py_NewRef(self->msg);
}
else {
return BaseException_str((PyBaseExceptionObject *)self);
return dict;
}
else if (dict) {
- Py_INCREF(dict);
- return dict;
+ return Py_NewRef(dict);
}
else {
Py_RETURN_NONE;
PyTuple_SET_ITEM(newargs, 0, *myerrno);
for (i = 1; i < nargs; i++) {
PyObject *val = PyTuple_GET_ITEM(args, i);
- Py_INCREF(val);
- PyTuple_SET_ITEM(newargs, i, val);
+ PyTuple_SET_ITEM(newargs, i, Py_NewRef(val));
}
Py_DECREF(args);
args = *p_args = newargs;
return -1;
}
else {
- Py_INCREF(filename);
- self->filename = filename;
+ self->filename = Py_NewRef(filename);
if (filename2 && filename2 != Py_None) {
- Py_INCREF(filename2);
- self->filename2 = filename2;
+ self->filename2 = Py_NewRef(filename2);
}
if (nargs >= 2 && nargs <= 5) {
}
}
}
- Py_XINCREF(myerrno);
- self->myerrno = myerrno;
-
- Py_XINCREF(strerror);
- self->strerror = strerror;
-
+ self->myerrno = Py_XNewRef(myerrno);
+ self->strerror = Py_XNewRef(strerror);
#ifdef MS_WINDOWS
- Py_XINCREF(winerror);
- self->winerror = winerror;
+ self->winerror = Py_XNewRef(winerror);
#endif
/* Steals the reference to args */
OSError_reduce(PyOSErrorObject *self, PyObject *Py_UNUSED(ignored))
{
PyObject *args = self->args;
- PyObject *res = NULL, *tmp;
+ PyObject *res = NULL;
/* self->args is only the first two real arguments if there was a
* file name given to OSError. */
if (!args)
return NULL;
- tmp = PyTuple_GET_ITEM(self->args, 0);
- Py_INCREF(tmp);
- PyTuple_SET_ITEM(args, 0, tmp);
-
- tmp = PyTuple_GET_ITEM(self->args, 1);
- Py_INCREF(tmp);
- PyTuple_SET_ITEM(args, 1, tmp);
-
- Py_INCREF(self->filename);
- PyTuple_SET_ITEM(args, 2, self->filename);
+ PyTuple_SET_ITEM(args, 0, Py_NewRef(PyTuple_GET_ITEM(self->args, 0)));
+ PyTuple_SET_ITEM(args, 1, Py_NewRef(PyTuple_GET_ITEM(self->args, 1)));
+ PyTuple_SET_ITEM(args, 2, Py_NewRef(self->filename));
if (self->filename2) {
/*
* So, to recreate filename2, we need to pass in
* winerror as well.
*/
- Py_INCREF(Py_None);
- PyTuple_SET_ITEM(args, 3, Py_None);
+ PyTuple_SET_ITEM(args, 3, Py_NewRef(Py_None));
/* filename2 */
- Py_INCREF(self->filename2);
- PyTuple_SET_ITEM(args, 4, self->filename2);
+ PyTuple_SET_ITEM(args, 4, Py_NewRef(self->filename2));
}
} else
Py_INCREF(args);
}
Py_DECREF(empty_tuple);
- Py_XINCREF(name);
- Py_XSETREF(self->name, name);
+ Py_XSETREF(self->name, Py_XNewRef(name));
return 0;
}
}
Py_DECREF(empty_tuple);
- Py_XINCREF(name);
- Py_XSETREF(self->name, name);
-
- Py_XINCREF(obj);
- Py_XSETREF(self->obj, obj);
+ Py_XSETREF(self->name, Py_XNewRef(name));
+ Py_XSETREF(self->obj, Py_XNewRef(obj));
return 0;
}
return -1;
if (lenargs >= 1) {
- Py_INCREF(PyTuple_GET_ITEM(args, 0));
- Py_XSETREF(self->msg, PyTuple_GET_ITEM(args, 0));
+ Py_XSETREF(self->msg, Py_NewRef(PyTuple_GET_ITEM(args, 0)));
}
if (lenargs == 2) {
info = PyTuple_GET_ITEM(args, 1);
return PyUnicode_Substring(name, offset, size);
}
else {
- Py_INCREF(name);
- return name;
+ return Py_NewRef(name);
}
}
PyErr_Format(PyExc_TypeError, "%.200s attribute must be bytes", name);
return NULL;
}
- Py_INCREF(attr);
- return attr;
+ return Py_NewRef(attr);
}
static PyObject *
"%.200s attribute must be unicode", name);
return NULL;
}
- Py_INCREF(attr);
- return attr;
+ return Py_NewRef(attr);
}
static int
}
}
else {
- Py_INCREF(Py_NotImplemented);
- *v = Py_NotImplemented;
+ *v = Py_NewRef(Py_NotImplemented);
return -1;
}
return 0;
PyExc_ValueError);
return NULL;
}
- Py_INCREF(o);
- return o;
+ return Py_NewRef(o);
}
/*[clinic input]
static PyObject *
float_float(PyObject *v)
{
- if (PyFloat_CheckExact(v))
- Py_INCREF(v);
- else
- v = PyFloat_FromDouble(((PyFloatObject *)v)->ob_fval);
- return v;
+ if (PyFloat_CheckExact(v)) {
+ return Py_NewRef(v);
+ }
+ else {
+ return PyFloat_FromDouble(((PyFloatObject *)v)->ob_fval);
+ }
}
/*[clinic input]
if (PyFrame_FastToLocalsWithError(f) < 0)
return NULL;
PyObject *locals = f->f_frame->f_locals;
- Py_INCREF(locals);
- return locals;
+ return Py_NewRef(locals);
}
int
if (globals == NULL) {
globals = Py_None;
}
- Py_INCREF(globals);
- return globals;
+ return Py_NewRef(globals);
}
static PyObject *
if (builtins == NULL) {
builtins = Py_None;
}
- Py_INCREF(builtins);
- return builtins;
+ return Py_NewRef(builtins);
}
static PyObject *
frame_gettrace(PyFrameObject *f, void *closure)
{
PyObject* trace = f->f_trace;
-
if (trace == NULL)
trace = Py_None;
-
- Py_INCREF(trace);
-
- return trace;
+ return Py_NewRef(trace);
}
static int
if (v == Py_None) {
v = NULL;
}
- Py_XINCREF(v);
- Py_XSETREF(f->f_trace, v);
-
+ Py_XSETREF(f->f_trace, Py_XNewRef(v));
return 0;
}
static void
init_frame(_PyInterpreterFrame *frame, PyFunctionObject *func, PyObject *locals)
{
- /* _PyFrame_InitializeSpecials consumes reference to func */
- Py_INCREF(func);
- Py_XINCREF(locals);
PyCodeObject *code = (PyCodeObject *)func->func_code;
- _PyFrame_InitializeSpecials(frame, func, locals, code);
+ _PyFrame_InitializeSpecials(frame, (PyFunctionObject*)Py_NewRef(func),
+ Py_XNewRef(locals), code);
for (Py_ssize_t i = 0; i < code->co_nlocalsplus; i++) {
frame->localsplus[i] = NULL;
}
int offset = co->co_nlocals + co->co_nplaincellvars;
for (int i = 0; i < co->co_nfreevars; ++i) {
PyObject *o = PyTuple_GET_ITEM(closure, i);
- Py_INCREF(o);
- frame->localsplus[offset + i] = o;
+ frame->localsplus[offset + i] = Py_NewRef(o);
}
// COPY_FREE_VARS doesn't have inline CACHEs, either:
frame->prev_instr = _PyCode_CODE(frame->f_code);
if (cell != NULL) {
oldvalue = PyCell_GET(cell);
if (value != oldvalue) {
- Py_XINCREF(value);
- PyCell_SET(cell, value);
+ PyCell_SET(cell, Py_XNewRef(value));
Py_XDECREF(oldvalue);
}
}
}
value = Py_NewRef(Py_None);
}
- Py_INCREF(value);
- Py_XSETREF(fast[i], value);
+ Py_XSETREF(fast[i], Py_NewRef(value));
}
Py_XDECREF(value);
}
assert(!_PyFrame_IsIncomplete(frame->f_frame));
PyCodeObject *code = frame->f_frame->f_code;
assert(code != NULL);
- Py_INCREF(code);
- return code;
+ return (PyCodeObject*)Py_NewRef(code);
}
back = _PyFrame_GetFrameObject(prev);
}
}
- Py_XINCREF(back);
- return back;
+ return (PyFrameObject*)Py_XNewRef(back);
}
PyObject*
if (op == NULL) {
return NULL;
}
- Py_INCREF(constr->fc_globals);
- op->func_globals = constr->fc_globals;
- Py_INCREF(constr->fc_builtins);
- op->func_builtins = constr->fc_builtins;
- Py_INCREF(constr->fc_name);
- op->func_name = constr->fc_name;
- Py_INCREF(constr->fc_qualname);
- op->func_qualname = constr->fc_qualname;
- Py_INCREF(constr->fc_code);
- op->func_code = constr->fc_code;
+ op->func_globals = Py_NewRef(constr->fc_globals);
+ op->func_builtins = Py_NewRef(constr->fc_builtins);
+ op->func_name = Py_NewRef(constr->fc_name);
+ op->func_qualname = Py_NewRef(constr->fc_qualname);
+ op->func_code = Py_NewRef(constr->fc_code);
op->func_defaults = NULL;
op->func_kwdefaults = NULL;
- Py_XINCREF(constr->fc_closure);
- op->func_closure = constr->fc_closure;
- Py_INCREF(Py_None);
- op->func_doc = Py_None;
+ op->func_closure = Py_XNewRef(constr->fc_closure);
+ op->func_doc = Py_NewRef(Py_None);
op->func_dict = NULL;
op->func_weakreflist = NULL;
op->func_module = NULL;
return NULL;
}
- Py_INCREF(op->func_code);
- return op->func_code;
+ return Py_NewRef(op->func_code);
}
static int
return -1;
}
op->func_version = 0;
- Py_INCREF(value);
- Py_XSETREF(op->func_code, value);
+ Py_XSETREF(op->func_code, Py_NewRef(value));
return 0;
}
static PyObject *
func_get_name(PyFunctionObject *op, void *Py_UNUSED(ignored))
{
- Py_INCREF(op->func_name);
- return op->func_name;
+ return Py_NewRef(op->func_name);
}
static int
"__name__ must be set to a string object");
return -1;
}
- Py_INCREF(value);
- Py_XSETREF(op->func_name, value);
+ Py_XSETREF(op->func_name, Py_NewRef(value));
return 0;
}
static PyObject *
func_get_qualname(PyFunctionObject *op, void *Py_UNUSED(ignored))
{
- Py_INCREF(op->func_qualname);
- return op->func_qualname;
+ return Py_NewRef(op->func_qualname);
}
static int
"__qualname__ must be set to a string object");
return -1;
}
- Py_INCREF(value);
- Py_XSETREF(op->func_qualname, value);
+ Py_XSETREF(op->func_qualname, Py_NewRef(value));
return 0;
}
if (op->func_defaults == NULL) {
Py_RETURN_NONE;
}
- Py_INCREF(op->func_defaults);
- return op->func_defaults;
+ return Py_NewRef(op->func_defaults);
}
static int
}
op->func_version = 0;
- Py_XINCREF(value);
- Py_XSETREF(op->func_defaults, value);
+ Py_XSETREF(op->func_defaults, Py_XNewRef(value));
return 0;
}
if (op->func_kwdefaults == NULL) {
Py_RETURN_NONE;
}
- Py_INCREF(op->func_kwdefaults);
- return op->func_kwdefaults;
+ return Py_NewRef(op->func_kwdefaults);
}
static int
}
op->func_version = 0;
- Py_XINCREF(value);
- Py_XSETREF(op->func_kwdefaults, value);
+ Py_XSETREF(op->func_kwdefaults, Py_XNewRef(value));
return 0;
}
return -1;
}
op->func_version = 0;
- Py_XINCREF(value);
- Py_XSETREF(op->func_annotations, value);
+ Py_XSETREF(op->func_annotations, Py_XNewRef(value));
return 0;
}
return NULL;
}
if (name != Py_None) {
- Py_INCREF(name);
- Py_SETREF(newfunc->func_name, name);
+ Py_SETREF(newfunc->func_name, Py_NewRef(name));
}
if (defaults != Py_None) {
- Py_INCREF(defaults);
- newfunc->func_defaults = defaults;
+ newfunc->func_defaults = Py_NewRef(defaults);
}
if (closure != Py_None) {
- Py_INCREF(closure);
- newfunc->func_closure = closure;
+ newfunc->func_closure = Py_NewRef(closure);
}
return (PyObject *)newfunc;
func_descr_get(PyObject *func, PyObject *obj, PyObject *type)
{
if (obj == Py_None || obj == NULL) {
- Py_INCREF(func);
- return func;
+ return Py_NewRef(func);
}
return PyMethod_New(func, obj);
}
return -1;
if (!PyArg_UnpackTuple(args, "classmethod", 1, 1, &callable))
return -1;
- Py_INCREF(callable);
- Py_XSETREF(cm->cm_callable, callable);
+ Py_XSETREF(cm->cm_callable, Py_NewRef(callable));
if (functools_wraps((PyObject *)cm, cm->cm_callable) < 0) {
return -1;
classmethod *cm = (classmethod *)
PyType_GenericAlloc(&PyClassMethod_Type, 0);
if (cm != NULL) {
- Py_INCREF(callable);
- cm->cm_callable = callable;
+ cm->cm_callable = Py_NewRef(callable);
}
return (PyObject *)cm;
}
"uninitialized staticmethod object");
return NULL;
}
- Py_INCREF(sm->sm_callable);
- return sm->sm_callable;
+ return Py_NewRef(sm->sm_callable);
}
static int
return -1;
if (!PyArg_UnpackTuple(args, "staticmethod", 1, 1, &callable))
return -1;
- Py_INCREF(callable);
- Py_XSETREF(sm->sm_callable, callable);
+ Py_XSETREF(sm->sm_callable, Py_NewRef(callable));
if (functools_wraps((PyObject *)sm, sm->sm_callable) < 0) {
return -1;
staticmethod *sm = (staticmethod *)
PyType_GenericAlloc(&PyStaticMethod_Type, 0);
if (sm != NULL) {
- Py_INCREF(callable);
- sm->sm_callable = callable;
+ sm->sm_callable = Py_NewRef(callable);
}
return (PyObject *)sm;
}
tuple_add(PyObject *self, Py_ssize_t len, PyObject *item)
{
if (tuple_index(self, len, item) < 0) {
- Py_INCREF(item);
- PyTuple_SET_ITEM(self, len, item);
+ PyTuple_SET_ITEM(self, len, Py_NewRef(item));
return 1;
}
return 0;
assert(dstindex + count <= PyTuple_GET_SIZE(*dst));
for (Py_ssize_t i = 0; i < count; ++i) {
PyObject *item = src[i];
- Py_INCREF(item);
- PyTuple_SET_ITEM(*dst, dstindex + i, item);
+ PyTuple_SET_ITEM(*dst, dstindex + i, Py_NewRef(item));
}
return dstindex + count;
}
continue;
}
}
- Py_INCREF(arg);
- PyTuple_SET_ITEM(subargs, j, arg);
+ PyTuple_SET_ITEM(subargs, j, Py_NewRef(arg));
j++;
}
assert(j == PyTuple_GET_SIZE(subargs));
((gaobject *)arg)->origin == (PyObject *)&PyTuple_Type)
{
result = ((gaobject *)arg)->args;
- Py_INCREF(result);
- return result;
+ return Py_NewRef(result);
}
if (_PyObject_LookupAttr(arg, &_Py_ID(__typing_unpacked_tuple_args__), &result) > 0) {
for (Py_ssize_t iarg = 0, jarg = 0; iarg < nargs; iarg++) {
PyObject *arg = PyTuple_GET_ITEM(args, iarg);
if (PyType_Check(arg)) {
- Py_INCREF(arg);
- PyTuple_SET_ITEM(newargs, jarg, arg);
+ PyTuple_SET_ITEM(newargs, jarg, Py_NewRef(arg));
jarg++;
continue;
}
return NULL;
}
}
- Py_INCREF(alias->parameters);
- return alias->parameters;
+ return Py_NewRef(alias->parameters);
}
static PyObject *
{
gaobject *alias = (gaobject *)self;
if (alias->starred && alias->origin == (PyObject *)&PyTuple_Type) {
- Py_INCREF(alias->args);
- return alias->args;
+ return Py_NewRef(alias->args);
}
Py_RETURN_NONE;
}
Py_INCREF(args);
}
- Py_INCREF(origin);
- alias->origin = origin;
+ alias->origin = Py_NewRef(origin);
alias->args = args;
alias->parameters = NULL;
alias->weakreflist = NULL;
else if (arg && !exc) {
/* `gen` is an exhausted generator:
only return value if called from send(). */
- *presult = Py_None;
- Py_INCREF(*presult);
+ *presult = Py_NewRef(Py_None);
return PYGEN_RETURN;
}
return PYGEN_ERROR;
assert(gen->gi_frame_state < FRAME_EXECUTING);
/* Push arg onto the frame's value stack */
result = arg ? arg : Py_None;
- Py_INCREF(result);
- _PyFrame_StackPush(frame, result);
+ _PyFrame_StackPush(frame, Py_NewRef(result));
_PyErr_StackItem *prev_exc_info = tstate->exc_info;
gen->gi_exc_state.previous_item = prev_exc_info;
if (ev) {
/* exception will usually be normalised already */
if (PyObject_TypeCheck(ev, (PyTypeObject *) et)) {
- value = ((PyStopIterationObject *)ev)->value;
- Py_INCREF(value);
+ value = Py_NewRef(((PyStopIterationObject *)ev)->value);
Py_DECREF(ev);
} else if (et == PyExc_StopIteration && !PyTuple_Check(ev)) {
/* Avoid normalisation and take ev as value.
PyErr_Restore(et, ev, tb);
return -1;
}
- value = ((PyStopIterationObject *)ev)->value;
- Py_INCREF(value);
+ value = Py_NewRef(((PyStopIterationObject *)ev)->value);
Py_DECREF(ev);
}
}
return -1;
}
if (value == NULL) {
- value = Py_None;
- Py_INCREF(value);
+ value = Py_NewRef(Py_None);
}
*pvalue = value;
return 0;
static PyObject *
gen_get_name(PyGenObject *op, void *Py_UNUSED(ignored))
{
- Py_INCREF(op->gi_name);
- return op->gi_name;
+ return Py_NewRef(op->gi_name);
}
static int
"__name__ must be set to a string object");
return -1;
}
- Py_INCREF(value);
- Py_XSETREF(op->gi_name, value);
+ Py_XSETREF(op->gi_name, Py_NewRef(value));
return 0;
}
static PyObject *
gen_get_qualname(PyGenObject *op, void *Py_UNUSED(ignored))
{
- Py_INCREF(op->gi_qualname);
- return op->gi_qualname;
+ return Py_NewRef(op->gi_qualname);
}
static int
"__qualname__ must be set to a string object");
return -1;
}
- Py_INCREF(value);
- Py_XSETREF(op->gi_qualname, value);
+ Py_XSETREF(op->gi_qualname, Py_NewRef(value));
return 0;
}
return NULL;
}
gen->gi_frame_state = FRAME_CLEARED;
- gen->gi_code = (PyCodeObject *)func->func_code;
- Py_INCREF(gen->gi_code);
+ gen->gi_code = (PyCodeObject *)Py_NewRef(func->func_code);
gen->gi_weakreflist = NULL;
gen->gi_exc_state.exc_value = NULL;
gen->gi_exc_state.previous_item = NULL;
gen->gi_exc_state.exc_value = NULL;
gen->gi_exc_state.previous_item = NULL;
if (name != NULL)
- gen->gi_name = name;
+ gen->gi_name = Py_NewRef(name);
else
- gen->gi_name = gen->gi_code->co_name;
- Py_INCREF(gen->gi_name);
+ gen->gi_name = Py_NewRef(gen->gi_code->co_name);
if (qualname != NULL)
- gen->gi_qualname = qualname;
+ gen->gi_qualname = Py_NewRef(qualname);
else
- gen->gi_qualname = gen->gi_code->co_qualname;
- Py_INCREF(gen->gi_qualname);
+ gen->gi_qualname = Py_NewRef(gen->gi_code->co_qualname);
_PyObject_GC_TRACK(gen);
return (PyObject *)gen;
}
if (PyCoro_CheckExact(o) || gen_is_coroutine(o)) {
/* 'o' is a coroutine. */
- Py_INCREF(o);
- return o;
+ return Py_NewRef(o);
}
ot = Py_TYPE(o);
if (cw == NULL) {
return NULL;
}
- Py_INCREF(coro);
- cw->cw_coroutine = coro;
+ cw->cw_coroutine = (PyCoroObject*)Py_NewRef(coro);
_PyObject_GC_TRACK(cw);
return (PyObject *)cw;
}
finalizer = tstate->async_gen_finalizer;
if (finalizer) {
- Py_INCREF(finalizer);
- o->ag_origin_or_finalizer = finalizer;
+ o->ag_origin_or_finalizer = Py_NewRef(finalizer);
}
firstiter = tstate->async_gen_firstiter;
}
}
- Py_INCREF(gen);
- o->ags_gen = gen;
+ o->ags_gen = (PyAsyncGenObject*)Py_NewRef(gen);
- Py_XINCREF(sendval);
- o->ags_sendval = sendval;
+ o->ags_sendval = Py_XNewRef(sendval);
o->ags_state = AWAITABLE_STATE_INIT;
return NULL;
}
}
- o->agw_val = val;
- Py_INCREF(val);
+ o->agw_val = Py_NewRef(val);
_PyObject_GC_TRACK((PyObject*)o);
return (PyObject*)o;
}
if (o == NULL) {
return NULL;
}
- o->agt_gen = gen;
- o->agt_args = args;
+ o->agt_gen = (PyAsyncGenObject*)Py_NewRef(gen);
+ o->agt_args = Py_XNewRef(args);
o->agt_state = AWAITABLE_STATE_INIT;
- Py_INCREF(gen);
- Py_XINCREF(args);
_PyObject_GC_TRACK((PyObject*)o);
return (PyObject*)o;
}
if (it == NULL)
return NULL;
it->it_index = 0;
- Py_INCREF(seq);
- it->it_seq = seq;
+ it->it_seq = Py_NewRef(seq);
_PyObject_GC_TRACK(it);
return (PyObject *)it;
}
it = PyObject_GC_New(calliterobject, &PyCallIter_Type);
if (it == NULL)
return NULL;
- Py_INCREF(callable);
- it->it_callable = callable;
- Py_INCREF(sentinel);
- it->it_sentinel = sentinel;
+ it->it_callable = Py_NewRef(callable);
+ it->it_sentinel = Py_NewRef(sentinel);
_PyObject_GC_TRACK(it);
return (PyObject *)it;
}
if (anext == NULL) {
return NULL;
}
- Py_INCREF(awaitable);
- anext->wrapped = awaitable;
- Py_INCREF(default_value);
- anext->default_value = default_value;
+ anext->wrapped = Py_NewRef(awaitable);
+ anext->default_value = Py_NewRef(default_value);
_PyObject_GC_TRACK(anext);
return (PyObject *)anext;
}