summaryrefslogtreecommitdiff
path: root/Modules/readline.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/readline.c')
-rw-r--r--Modules/readline.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/Modules/readline.c b/Modules/readline.c
index 27b89de727..fdb6356e1c 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -402,8 +402,7 @@ set_hook(const char *funcname, PyObject **hook_var, PyObject *function)
Py_CLEAR(*hook_var);
}
else if (PyCallable_Check(function)) {
- Py_INCREF(function);
- Py_XSETREF(*hook_var, function);
+ Py_XSETREF(*hook_var, Py_NewRef(function));
}
else {
PyErr_Format(PyExc_TypeError,
@@ -524,8 +523,7 @@ static PyObject *
readline_get_begidx_impl(PyObject *module)
/*[clinic end generated code: output=362616ee8ed1b2b1 input=e083b81c8eb4bac3]*/
{
- Py_INCREF(readlinestate_global->begidx);
- return readlinestate_global->begidx;
+ return Py_NewRef(readlinestate_global->begidx);
}
/* Get the ending index for the scope of the tab-completion */
@@ -540,8 +538,7 @@ static PyObject *
readline_get_endidx_impl(PyObject *module)
/*[clinic end generated code: output=7f763350b12d7517 input=d4c7e34a625fd770]*/
{
- Py_INCREF(readlinestate_global->endidx);
- return readlinestate_global->endidx;
+ return Py_NewRef(readlinestate_global->endidx);
}
/* Set the tab-completion word-delimiters that readline uses */
@@ -784,8 +781,7 @@ readline_get_completer_impl(PyObject *module)
if (readlinestate_global->completer == NULL) {
Py_RETURN_NONE;
}
- Py_INCREF(readlinestate_global->completer);
- return readlinestate_global->completer;
+ return Py_NewRef(readlinestate_global->completer);
}
/* Private function to get current length of history. XXX It may be