diff options
Diffstat (limited to 'Modules/mmapmodule.c')
-rw-r--r-- | Modules/mmapmodule.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index d39169a..5afe715 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -206,7 +206,7 @@ mmap_read_line_method(mmap_object *self, else ++eol; /* we're interested in the position after the newline. */ - result = PyString_FromStringAndSize(start, (eol - start)); + result = PyBytes_FromStringAndSize(start, (eol - start)); self->pos += (eol - start); return result; } @@ -659,7 +659,7 @@ mmap_item(mmap_object *self, Py_ssize_t i) PyErr_SetString(PyExc_IndexError, "mmap index out of range"); return NULL; } - return PyString_FromStringAndSize(self->data + i, 1); + return PyBytes_FromStringAndSize(self->data + i, 1); } static PyObject * @@ -677,7 +677,7 @@ mmap_slice(mmap_object *self, Py_ssize_t ilow, Py_ssize_t ihigh) else if ((size_t)ihigh > self->size) ihigh = self->size; - return PyString_FromStringAndSize(self->data + ilow, ihigh-ilow); + return PyBytes_FromStringAndSize(self->data + ilow, ihigh-ilow); } static PyObject * @@ -720,19 +720,19 @@ mmap_ass_slice(mmap_object *self, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v "mmap object doesn't support slice deletion"); return -1; } - if (! (PyString_Check(v)) ) { + if (! (PyBytes_Check(v)) ) { PyErr_SetString(PyExc_IndexError, - "mmap slice assignment must be a string"); + "mmap slice assignment must be bytes"); return -1; } - if (PyString_Size(v) != (ihigh - ilow)) { + if (PyBytes_Size(v) != (ihigh - ilow)) { PyErr_SetString(PyExc_IndexError, "mmap slice assignment is wrong size"); return -1; } if (!is_writeable(self)) return -1; - buf = PyString_AsString(v); + buf = PyBytes_AsString(v); memcpy(self->data + ilow, buf, ihigh-ilow); return 0; } @@ -752,14 +752,14 @@ mmap_ass_item(mmap_object *self, Py_ssize_t i, PyObject *v) "mmap object doesn't support item deletion"); return -1; } - if (! (PyString_Check(v) && PyString_Size(v)==1) ) { + if (! (PyBytes_Check(v) && PyBytes_Size(v)==1) ) { PyErr_SetString(PyExc_IndexError, "mmap assignment must be single-character string"); return -1; } if (!is_writeable(self)) return -1; - buf = PyString_AsString(v); + buf = PyBytes_AsString(v); self->data[i] = buf[0]; return 0; } |