mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-42161: Use _PyLong_GetZero() and _PyLong_GetOne() (GH-22995)
Use _PyLong_GetZero() and _PyLong_GetOne() in Objects/ and Python/ directories.
This commit is contained in:
parent
303aac8c56
commit
c9bc290dd6
9 changed files with 68 additions and 40 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "Python.h"
|
||||
#include "pycore_initconfig.h"
|
||||
#include "pycore_interp.h" // PyInterpreterState.warnings
|
||||
#include "pycore_long.h" // _PyLong_GetZero()
|
||||
#include "pycore_pyerrors.h"
|
||||
#include "pycore_pystate.h" // _PyThreadState_GET()
|
||||
#include "frameobject.h" // PyFrame_GetBack()
|
||||
|
@ -73,7 +74,7 @@ create_filter(PyObject *category, _Py_Identifier *id, const char *modname)
|
|||
|
||||
/* This assumes the line number is zero for now. */
|
||||
return PyTuple_Pack(5, action_str, Py_None,
|
||||
category, modname_obj, _PyLong_Zero);
|
||||
category, modname_obj, _PyLong_GetZero());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -472,7 +473,7 @@ update_registry(PyObject *registry, PyObject *text, PyObject *category,
|
|||
int rc;
|
||||
|
||||
if (add_zero)
|
||||
altkey = PyTuple_Pack(3, text, category, _PyLong_Zero);
|
||||
altkey = PyTuple_Pack(3, text, category, _PyLong_GetZero());
|
||||
else
|
||||
altkey = PyTuple_Pack(2, text, category);
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
#include "Python.h"
|
||||
#include "pycore_long.h" // _PyLong_GetZero()
|
||||
|
||||
#include "Python-ast.h"
|
||||
#include "ast.h"
|
||||
|
@ -603,7 +604,7 @@ compiler_enter_scope(struct compiler *c, identifier name,
|
|||
compiler_unit_free(u);
|
||||
return 0;
|
||||
}
|
||||
res = PyDict_SetItem(u->u_cellvars, name, _PyLong_Zero);
|
||||
res = PyDict_SetItem(u->u_cellvars, name, _PyLong_GetZero());
|
||||
if (res < 0) {
|
||||
compiler_unit_free(u);
|
||||
return 0;
|
||||
|
@ -3218,11 +3219,12 @@ compiler_import(struct compiler *c, stmt_ty s)
|
|||
*/
|
||||
Py_ssize_t i, n = asdl_seq_LEN(s->v.Import.names);
|
||||
|
||||
PyObject *zero = _PyLong_GetZero(); // borrowed reference
|
||||
for (i = 0; i < n; i++) {
|
||||
alias_ty alias = (alias_ty)asdl_seq_GET(s->v.Import.names, i);
|
||||
int r;
|
||||
|
||||
ADDOP_LOAD_CONST(c, _PyLong_Zero);
|
||||
ADDOP_LOAD_CONST(c, zero);
|
||||
ADDOP_LOAD_CONST(c, Py_None);
|
||||
ADDOP_NAME(c, IMPORT_NAME, alias->name, names);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue