mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
gh-99300: Use Py_NewRef() in Python/ directory (#99302)
Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in C files of the Python/ directory.
This commit is contained in:
parent
f883b7f8ee
commit
d8f239d86e
14 changed files with 41 additions and 80 deletions
|
@ -382,8 +382,7 @@ get_filter(PyInterpreterState *interp, PyObject *category,
|
|||
|
||||
action = get_default_action(interp);
|
||||
if (action != NULL) {
|
||||
Py_INCREF(Py_None);
|
||||
*item = Py_None;
|
||||
*item = Py_NewRef(Py_None);
|
||||
return action;
|
||||
}
|
||||
|
||||
|
@ -468,8 +467,7 @@ normalize_module(PyObject *filename)
|
|||
module = PyUnicode_Substring(filename, 0, len-3);
|
||||
}
|
||||
else {
|
||||
module = filename;
|
||||
Py_INCREF(module);
|
||||
module = Py_NewRef(filename);
|
||||
}
|
||||
return module;
|
||||
}
|
||||
|
@ -751,8 +749,7 @@ warn_explicit(PyThreadState *tstate, PyObject *category, PyObject *message,
|
|||
goto cleanup;
|
||||
|
||||
return_none:
|
||||
result = Py_None;
|
||||
Py_INCREF(result);
|
||||
result = Py_NewRef(Py_None);
|
||||
|
||||
cleanup:
|
||||
Py_XDECREF(item);
|
||||
|
@ -848,8 +845,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
|
|||
}
|
||||
else {
|
||||
globals = f->f_frame->f_globals;
|
||||
*filename = f->f_frame->f_code->co_filename;
|
||||
Py_INCREF(*filename);
|
||||
*filename = Py_NewRef(f->f_frame->f_code->co_filename);
|
||||
*lineno = PyFrame_GetLineNumber(f);
|
||||
Py_DECREF(f);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue