summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-03-30 06:09:41 (GMT)
committerGitHub <noreply@github.com>2017-03-30 06:09:41 (GMT)
commitba85d69a3e3610bdd05f0dd372cf4ebca178c7fb (patch)
treefe0766c34601880610c3399a8f01c35ab6e8fe8e /Python/compile.c
parente6911a44f69c0d302db60f49952a9cf69da69a2b (diff)
downloadcpython-ba85d69a3e3610bdd05f0dd372cf4ebca178c7fb.zip
cpython-ba85d69a3e3610bdd05f0dd372cf4ebca178c7fb.tar.gz
cpython-ba85d69a3e3610bdd05f0dd372cf4ebca178c7fb.tar.bz2
bpo-29878: Add global instances of int for 0 and 1. (#852)
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 064364e..b630863 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -561,7 +561,7 @@ compiler_enter_scope(struct compiler *c, identifier name,
if (u->u_ste->ste_needs_class_closure) {
/* Cook up an implicit __class__ cell. */
_Py_IDENTIFIER(__class__);
- PyObject *tuple, *name, *zero;
+ PyObject *tuple, *name;
int res;
assert(u->u_scope_type == COMPILER_SCOPE_CLASS);
assert(PyDict_GET_SIZE(u->u_cellvars) == 0);
@@ -575,15 +575,8 @@ compiler_enter_scope(struct compiler *c, identifier name,
compiler_unit_free(u);
return 0;
}
- zero = PyLong_FromLong(0);
- if (!zero) {
- Py_DECREF(tuple);
- compiler_unit_free(u);
- return 0;
- }
- res = PyDict_SetItem(u->u_cellvars, tuple, zero);
+ res = PyDict_SetItem(u->u_cellvars, tuple, _PyLong_Zero);
Py_DECREF(tuple);
- Py_DECREF(zero);
if (res < 0) {
compiler_unit_free(u);
return 0;
@@ -2596,14 +2589,8 @@ compiler_import(struct compiler *c, stmt_ty s)
for (i = 0; i < n; i++) {
alias_ty alias = (alias_ty)asdl_seq_GET(s->v.Import.names, i);
int r;
- PyObject *level;
- level = PyLong_FromLong(0);
- if (level == NULL)
- return 0;
-
- ADDOP_O(c, LOAD_CONST, level, consts);
- Py_DECREF(level);
+ ADDOP_O(c, LOAD_CONST, _PyLong_Zero, consts);
ADDOP_O(c, LOAD_CONST, Py_None, consts);
ADDOP_NAME(c, IMPORT_NAME, alias->name, names);