summaryrefslogtreecommitdiffstats
path: root/Objects/enumobject.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 /Objects/enumobject.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 'Objects/enumobject.c')
-rw-r--r--Objects/enumobject.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/Objects/enumobject.c b/Objects/enumobject.c
index 480768f..3eb1736 100644
--- a/Objects/enumobject.c
+++ b/Objects/enumobject.c
@@ -100,7 +100,6 @@ enum_traverse(enumobject *en, visitproc visit, void *arg)
static PyObject *
enum_next_long(enumobject *en, PyObject* next_item)
{
- static PyObject *one = NULL;
PyObject *result = en->en_result;
PyObject *next_index;
PyObject *stepped_up;
@@ -110,14 +109,9 @@ enum_next_long(enumobject *en, PyObject* next_item)
if (en->en_longindex == NULL)
return NULL;
}
- if (one == NULL) {
- one = PyLong_FromLong(1);
- if (one == NULL)
- return NULL;
- }
next_index = en->en_longindex;
assert(next_index != NULL);
- stepped_up = PyNumber_Add(next_index, one);
+ stepped_up = PyNumber_Add(next_index, _PyLong_One);
if (stepped_up == NULL)
return NULL;
en->en_longindex = stepped_up;