diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-03-30 06:09:41 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-30 06:09:41 (GMT) |
commit | ba85d69a3e3610bdd05f0dd372cf4ebca178c7fb (patch) | |
tree | fe0766c34601880610c3399a8f01c35ab6e8fe8e /Modules/_datetimemodule.c | |
parent | e6911a44f69c0d302db60f49952a9cf69da69a2b (diff) | |
download | cpython-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 'Modules/_datetimemodule.c')
-rw-r--r-- | Modules/_datetimemodule.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index 1803d85..3661c78 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -1481,7 +1481,6 @@ cmperror(PyObject *a, PyObject *b) */ /* Conversion factors. */ -static PyObject *one = NULL; /* 1 */ static PyObject *us_per_ms = NULL; /* 1000 */ static PyObject *us_per_second = NULL; /* 1000000 */ static PyObject *us_per_minute = NULL; /* 1e6 * 60 as Python int */ @@ -2201,7 +2200,7 @@ delta_new(PyTypeObject *type, PyObject *args, PyObject *kw) goto Done if (us) { - y = accum("microseconds", x, us, one, &leftover_us); + y = accum("microseconds", x, us, _PyLong_One, &leftover_us); CLEANUP; } if (ms) { @@ -2241,7 +2240,7 @@ delta_new(PyTypeObject *type, PyObject *args, PyObject *kw) * is odd. Note that x is odd when it's last bit is 1. The * code below uses bitwise and operation to check the last * bit. */ - temp = PyNumber_And(x, one); /* temp <- x & 1 */ + temp = PyNumber_And(x, _PyLong_One); /* temp <- x & 1 */ if (temp == NULL) { Py_DECREF(x); goto Done; @@ -5839,12 +5838,11 @@ PyInit__datetime(void) Py_BUILD_ASSERT(DI100Y == 25 * DI4Y - 1); assert(DI100Y == days_before_year(100+1)); - one = PyLong_FromLong(1); us_per_ms = PyLong_FromLong(1000); us_per_second = PyLong_FromLong(1000000); us_per_minute = PyLong_FromLong(60000000); seconds_per_day = PyLong_FromLong(24 * 3600); - if (one == NULL || us_per_ms == NULL || us_per_second == NULL || + if (us_per_ms == NULL || us_per_second == NULL || us_per_minute == NULL || seconds_per_day == NULL) return NULL; |