diff options
author | Guido van Rossum <guido@python.org> | 2007-07-16 19:29:02 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-07-16 19:29:02 (GMT) |
commit | b358a2c4233f0e8c3cc58b86ed84007cc16ea74d (patch) | |
tree | fae988b888e2ce5ccb2daba682f3c3a7894d206f /Modules/mmapmodule.c | |
parent | 88079f472ec290975f10f9bc02b24b67e4df60fa (diff) | |
download | cpython-b358a2c4233f0e8c3cc58b86ed84007cc16ea74d.zip cpython-b358a2c4233f0e8c3cc58b86ed84007cc16ea74d.tar.gz cpython-b358a2c4233f0e8c3cc58b86ed84007cc16ea74d.tar.bz2 |
SF patch# 1752647 by Joe Gregorio.
Fixes to make test_mmap.py pass unit tests.
Moves the interface from being string based to being bytes based.
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; } |