summaryrefslogtreecommitdiff
path: root/Objects/sliceobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-03-30 09:09:41 +0300
committerGitHub <noreply@github.com>2017-03-30 09:09:41 +0300
commitba85d69a3e3610bdd05f0dd372cf4ebca178c7fb (patch)
treefe0766c34601880610c3399a8f01c35ab6e8fe8e /Objects/sliceobject.c
parente6911a44f69c0d302db60f49952a9cf69da69a2b (diff)
downloadcpython-git-ba85d69a3e3610bdd05f0dd372cf4ebca178c7fb.tar.gz
bpo-29878: Add global instances of int for 0 and 1. (#852)
Diffstat (limited to 'Objects/sliceobject.c')
-rw-r--r--Objects/sliceobject.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c
index d41ac105f6..ebc44642fe 100644
--- a/Objects/sliceobject.c
+++ b/Objects/sliceobject.c
@@ -374,9 +374,8 @@ _PySlice_GetLongIndices(PySliceObject *self, PyObject *length,
/* Convert step to an integer; raise for zero step. */
if (self->step == Py_None) {
- step = PyLong_FromLong(1L);
- if (step == NULL)
- goto error;
+ step = _PyLong_One;
+ Py_INCREF(step);
step_is_negative = 0;
}
else {
@@ -404,10 +403,8 @@ _PySlice_GetLongIndices(PySliceObject *self, PyObject *length,
goto error;
}
else {
- lower = PyLong_FromLong(0L);
- if (lower == NULL)
- goto error;
-
+ lower = _PyLong_Zero;
+ Py_INCREF(lower);
upper = length;
Py_INCREF(upper);
}