New submission from Hirokazu Yamamoto <ocean-c...@m2.ccsnet.ne.jp>:

It seems mmap module is using inappropriate exception types. For example,

        if (! (PyString_Check(v)) ) {
                PyErr_SetString(PyExc_IndexError,
                                "mmap slice assignment must be a string");
                return -1;
        }

I think this should be PyExc_TypeError.

                if (self->size >= pos && count > self->size - pos) {
                        PyErr_SetString(PyExc_ValueError,
                                        "source or destination out of range");
                        return NULL;

I think this is out of range, so PyExc_IndexError.

Of course, there is the case difficult to determine which exception is
suitable. For example, if Py_ssize_t is negative value, OverflowError or
IndexError?

----------
messages: 82849
nosy: ocean-city
severity: normal
status: open
title: mmap and exception type
type: behavior
versions: Python 2.7, Python 3.1

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5384>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to