aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-10-27 02:24:34 +0100
committerGitHub <noreply@github.com>2020-10-27 02:24:34 +0100
commitc9bc290dd6e3994a4ead2a224178bcba86f0c0e4 (patch)
treef3a4e137da850af0438119da460877c3a4fd8532 /Python/compile.c
parentbpo-30681: Support invalid date format or value in email Date header (GH-22090) (diff)
downloadcpython-c9bc290dd6e3994a4ead2a224178bcba86f0c0e4.tar.gz
cpython-c9bc290dd6e3994a4ead2a224178bcba86f0c0e4.tar.bz2
cpython-c9bc290dd6e3994a4ead2a224178bcba86f0c0e4.zip
bpo-42161: Use _PyLong_GetZero() and _PyLong_GetOne() (GH-22995)
Use _PyLong_GetZero() and _PyLong_GetOne() in Objects/ and Python/ directories.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c
index a0089b2d6dc..15a9046065b 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -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);