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/_io | |
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/_io')
-rw-r--r-- | Modules/_io/_iomodule.c | 4 | ||||
-rw-r--r-- | Modules/_io/_iomodule.h | 1 | ||||
-rw-r--r-- | Modules/_io/textio.c | 14 |
3 files changed, 7 insertions, 12 deletions
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c index 5d804ec..0b795c8 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -53,7 +53,6 @@ PyObject *_PyIO_str_write; PyObject *_PyIO_empty_str; PyObject *_PyIO_empty_bytes; -PyObject *_PyIO_zero; PyDoc_STRVAR(module_doc, "The io module provides the Python interfaces to stream handling. The\n" @@ -790,9 +789,6 @@ PyInit__io(void) if (!_PyIO_empty_bytes && !(_PyIO_empty_bytes = PyBytes_FromStringAndSize(NULL, 0))) goto fail; - if (!_PyIO_zero && - !(_PyIO_zero = PyLong_FromLong(0L))) - goto fail; state->initialized = 1; diff --git a/Modules/_io/_iomodule.h b/Modules/_io/_iomodule.h index daaebd2..b5f0f57 100644 --- a/Modules/_io/_iomodule.h +++ b/Modules/_io/_iomodule.h @@ -183,6 +183,5 @@ extern PyObject *_PyIO_str_write; extern PyObject *_PyIO_empty_str; extern PyObject *_PyIO_empty_bytes; -extern PyObject *_PyIO_zero; extern PyTypeObject _PyBytesIOBuffer_Type; diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index fce662a..0211ad9 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -1078,7 +1078,7 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer, if (cookieObj == NULL) goto error; - cmp = PyObject_RichCompareBool(cookieObj, _PyIO_zero, Py_EQ); + cmp = PyObject_RichCompareBool(cookieObj, _PyLong_Zero, Py_EQ); Py_DECREF(cookieObj); if (cmp < 0) { goto error; @@ -1087,7 +1087,7 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer, if (cmp == 0) { self->encoding_start_of_stream = 0; res = PyObject_CallMethodObjArgs(self->encoder, _PyIO_str_setstate, - _PyIO_zero, NULL); + _PyLong_Zero, NULL); if (res == NULL) goto error; Py_DECREF(res); @@ -2030,7 +2030,7 @@ _textiowrapper_encoder_reset(textio *self, int start_of_stream) } else { res = PyObject_CallMethodObjArgs(self->encoder, _PyIO_str_setstate, - _PyIO_zero, NULL); + _PyLong_Zero, NULL); self->encoding_start_of_stream = 0; } if (res == NULL) @@ -2075,7 +2075,7 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence) if (whence == 1) { /* seek relative to current position */ - cmp = PyObject_RichCompareBool(cookieObj, _PyIO_zero, Py_EQ); + cmp = PyObject_RichCompareBool(cookieObj, _PyLong_Zero, Py_EQ); if (cmp < 0) goto fail; @@ -2094,7 +2094,7 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence) } else if (whence == 2) { /* seek relative to end of file */ - cmp = PyObject_RichCompareBool(cookieObj, _PyIO_zero, Py_EQ); + cmp = PyObject_RichCompareBool(cookieObj, _PyLong_Zero, Py_EQ); if (cmp < 0) goto fail; @@ -2123,7 +2123,7 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence) goto fail; if (self->encoder) { /* If seek() == 0, we are at the start of stream, otherwise not */ - cmp = PyObject_RichCompareBool(res, _PyIO_zero, Py_EQ); + cmp = PyObject_RichCompareBool(res, _PyLong_Zero, Py_EQ); if (cmp < 0 || _textiowrapper_encoder_reset(self, cmp)) { Py_DECREF(res); goto fail; @@ -2137,7 +2137,7 @@ _io_TextIOWrapper_seek_impl(textio *self, PyObject *cookieObj, int whence) goto fail; } - cmp = PyObject_RichCompareBool(cookieObj, _PyIO_zero, Py_LT); + cmp = PyObject_RichCompareBool(cookieObj, _PyLong_Zero, Py_LT); if (cmp < 0) goto fail; |