return NULL;
}
- Py_XINCREF(result);
- return result;
+ return Py_XNewRef(result);
}
/* Issue #4701: Check that PyObject_Hash implicitly calls
if (args == NULL) {
args = Py_None;
}
- Py_INCREF(args);
- return args;
+ return Py_NewRef(args);
}
static PyObject *
if (kwargs == NULL) {
kwargs = Py_None;
}
- Py_INCREF(kwargs);
- return kwargs;
+ return Py_NewRef(kwargs);
}
/* Test tuple argument processing */
PyObject *obj;
if (!PyArg_ParseTuple(args, "S", &obj))
return NULL;
- Py_INCREF(obj);
- return obj;
+ return Py_NewRef(obj);
}
static PyObject *
PyObject *obj;
if (!PyArg_ParseTuple(args, "Y", &obj))
return NULL;
- Py_INCREF(obj);
- return obj;
+ return Py_NewRef(obj);
}
static PyObject *
PyObject *obj;
if (!PyArg_ParseTuple(args, "U", &obj))
return NULL;
- Py_INCREF(obj);
- return obj;
+ return Py_NewRef(obj);
}
static PyObject *
if (buffer.buf != NULL)
bytes = PyBytes_FromStringAndSize(buffer.buf, buffer.len);
else {
- Py_INCREF(Py_None);
- bytes = Py_None;
+ bytes = Py_NewRef(Py_None);
}
PyBuffer_Release(&buffer);
return bytes;
buffers + 4, buffers + 5, buffers + 6, buffers + 7);
if (result) {
- return_value = Py_None;
- Py_INCREF(Py_None);
+ return_value = Py_NewRef(Py_None);
}
exit:
return NULL;
}
if (macro) {
- Py_INCREF(PyDateTime_TimeZone_UTC);
- return PyDateTime_TimeZone_UTC;
+ return Py_NewRef(PyDateTime_TimeZone_UTC);
} else {
- Py_INCREF(PyDateTimeAPI->TimeZone_UTC);
- return PyDateTimeAPI->TimeZone_UTC;
+ return Py_NewRef(PyDateTimeAPI->TimeZone_UTC);
}
}
{
/* Clone str1, then let the conversion fail. */
assert(str1);
- str2 = str1;
- Py_INCREF(str2);
+ str2 = Py_NewRef(str1);
return 0;
}
static PyObject*
return NULL;
}
tp->tp_del = slot_tp_del;
- Py_INCREF(obj);
- return obj;
+ return Py_NewRef(obj);
}
static PyObject *
tp->tp_clear = NULL;
}
assert(!PyType_IS_GC(tp));
- Py_INCREF(obj);
- return obj;
+ return Py_NewRef(obj);
}
static PyMethodDef ml;
static PyObject *
_test_incref(PyObject *ob)
{
- Py_INCREF(ob);
- return ob;
+ return Py_NewRef(ob);
}
static PyObject *
goto fail;
}
- Py_INCREF(Py_None);
- res = Py_None;
+ res = Py_NewRef(Py_None);
goto finally;
fail:
goto exit;
}
- Py_INCREF(callback);
- test_c_thread.callback = callback;
+ test_c_thread.callback = Py_NewRef(callback);
PyThread_acquire_lock(test_c_thread.start_event, 1);
PyThread_acquire_lock(test_c_thread.exit_event, 1);
PyThread_release_lock(test_c_thread.exit_event);
Py_END_ALLOW_THREADS
- Py_INCREF(Py_None);
- res = Py_None;
+ res = Py_NewRef(Py_None);
exit:
Py_CLEAR(test_c_thread.callback);
if (obj == NULL) {
Py_RETURN_NONE;
}
- Py_INCREF(obj);
- return obj;
+ return Py_NewRef(obj);
}
static PyObject*
PyErr_SetString(PyExc_RuntimeError, "no watchers active");
return NULL;
}
- Py_INCREF(g_dict_watch_events);
- return g_dict_watch_events;
+ return Py_NewRef(g_dict_watch_events);
}
{
PyObject *code = PyFunction_GetCode(func);
if (code != NULL) {
- Py_INCREF(code);
- return code;
+ return Py_NewRef(code);
} else {
return NULL;
}
{
PyObject *globals = PyFunction_GetGlobals(func);
if (globals != NULL) {
- Py_INCREF(globals);
- return globals;
+ return Py_NewRef(globals);
} else {
return NULL;
}
{
PyObject *module = PyFunction_GetModule(func);
if (module != NULL) {
- Py_INCREF(module);
- return module;
+ return Py_NewRef(module);
} else {
return NULL;
}
{
PyObject *defaults = PyFunction_GetDefaults(func);
if (defaults != NULL) {
- Py_INCREF(defaults);
- return defaults;
+ return Py_NewRef(defaults);
} else if (PyErr_Occurred()) {
return NULL;
} else {
{
PyObject *defaults = PyFunction_GetKwDefaults(func);
if (defaults != NULL) {
- Py_INCREF(defaults);
- return defaults;
+ return Py_NewRef(defaults);
} else if (PyErr_Occurred()) {
return NULL;
} else {
PyErr_SetString(PyExc_RuntimeError, "no watchers active");
return NULL;
}
- Py_INCREF(g_type_modified_events);
- return g_type_modified_events;
+ return Py_NewRef(g_type_modified_events);
}
static PyObject *
return NULL;
}
- Py_INCREF(v);
- ao->ao_iterator = v;
+ ao->ao_iterator = Py_NewRef(v);
return (PyObject *)ao;
}
static PyObject *
awaitObject_await(awaitObject *ao)
{
- Py_INCREF(ao->ao_iterator);
- return ao->ao_iterator;
+ return Py_NewRef(ao->ao_iterator);
}
static PyAsyncMethods awaitType_as_async = {
if (o == NULL) {
return NULL;
}
- Py_INCREF(item);
- o->item = item;
+ o->item = Py_NewRef(item);
return (PyObject*) o;
}