diff options
Diffstat (limited to 'Modules/mmapmodule.c')
-rw-r--r-- | Modules/mmapmodule.c | 25 |
1 files changed, 1 insertions, 24 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 7c15d37..56f4400 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -240,29 +240,6 @@ mmap_read_line_method(mmap_object *self, return result; } -/* Basically the "n" format code with the ability to turn None into -1. */ -static int -mmap_convert_ssize_t(PyObject *obj, void *result) { - Py_ssize_t limit; - if (obj == Py_None) { - limit = -1; - } - else if (PyIndex_Check(obj)) { - limit = PyNumber_AsSsize_t(obj, PyExc_OverflowError); - if (limit == -1 && PyErr_Occurred()) { - return 0; - } - } - else { - PyErr_Format(PyExc_TypeError, - "argument should be integer or None, not '%.200s'", - Py_TYPE(obj)->tp_name); - return 0; - } - *((Py_ssize_t *)result) = limit; - return 1; -} - static PyObject * mmap_read_method(mmap_object *self, PyObject *args) @@ -271,7 +248,7 @@ mmap_read_method(mmap_object *self, PyObject *result; CHECK_VALID(NULL); - if (!PyArg_ParseTuple(args, "|O&:read", mmap_convert_ssize_t, &num_bytes)) + if (!PyArg_ParseTuple(args, "|O&:read", _Py_convert_optional_to_ssize_t, &num_bytes)) return(NULL); /* silently 'adjust' out-of-range requests */ |