diff options
author | Thomas Wouters <thomas@python.org> | 2007-08-30 22:57:53 (GMT) |
---|---|---|
committer | Thomas Wouters <thomas@python.org> | 2007-08-30 22:57:53 (GMT) |
commit | d2cf20eea2338a0369d4a5707adb01b201f7dfb2 (patch) | |
tree | 59fd4a094906997ae2b0cd520ff09010457da680 /Modules/mmapmodule.c | |
parent | 582b5866174d20f7c027cbb6fb757fefb382f96f (diff) | |
download | cpython-d2cf20eea2338a0369d4a5707adb01b201f7dfb2.zip cpython-d2cf20eea2338a0369d4a5707adb01b201f7dfb2.tar.gz cpython-d2cf20eea2338a0369d4a5707adb01b201f7dfb2.tar.bz2 |
Remove the simple slicing API. All slicing is now done with slice objects.
Diffstat (limited to 'Modules/mmapmodule.c')
-rw-r--r-- | Modules/mmapmodule.c | 61 |
1 files changed, 2 insertions, 59 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index f3727e3..77f64bc 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -642,24 +642,6 @@ mmap_item(mmap_object *self, Py_ssize_t i) } static PyObject * -mmap_slice(mmap_object *self, Py_ssize_t ilow, Py_ssize_t ihigh) -{ - CHECK_VALID(NULL); - if (ilow < 0) - ilow = 0; - else if ((size_t)ilow > self->size) - ilow = self->size; - if (ihigh < 0) - ihigh = 0; - if (ihigh < ilow) - ihigh = ilow; - else if ((size_t)ihigh > self->size) - ihigh = self->size; - - return PyBytes_FromStringAndSize(self->data + ilow, ihigh-ilow); -} - -static PyObject * mmap_subscript(mmap_object *self, PyObject *item) { CHECK_VALID(NULL); @@ -732,45 +714,6 @@ mmap_repeat(mmap_object *self, Py_ssize_t n) } static int -mmap_ass_slice(mmap_object *self, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v) -{ - const char *buf; - - CHECK_VALID(-1); - if (ilow < 0) - ilow = 0; - else if ((size_t)ilow > self->size) - ilow = self->size; - if (ihigh < 0) - ihigh = 0; - if (ihigh < ilow) - ihigh = ilow; - else if ((size_t)ihigh > self->size) - ihigh = self->size; - - if (v == NULL) { - PyErr_SetString(PyExc_TypeError, - "mmap object doesn't support slice deletion"); - return -1; - } - if (! (PyBytes_Check(v)) ) { - PyErr_SetString(PyExc_IndexError, - "mmap slice assignment must be bytes"); - return -1; - } - 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 = PyBytes_AsString(v); - memcpy(self->data + ilow, buf, ihigh-ilow); - return 0; -} - -static int mmap_ass_item(mmap_object *self, Py_ssize_t i, PyObject *v) { const char *buf; @@ -892,9 +835,9 @@ static PySequenceMethods mmap_as_sequence = { (binaryfunc)mmap_concat, /*sq_concat*/ (ssizeargfunc)mmap_repeat, /*sq_repeat*/ (ssizeargfunc)mmap_item, /*sq_item*/ - (ssizessizeargfunc)mmap_slice, /*sq_slice*/ + 0, /*sq_slice*/ (ssizeobjargproc)mmap_ass_item, /*sq_ass_item*/ - (ssizessizeobjargproc)mmap_ass_slice, /*sq_ass_slice*/ + 0, /*sq_ass_slice*/ }; static PyMappingMethods mmap_as_mapping = { |