[issue5384] mmap and exception type

Hirokazu Yamamoto report at bugs.python.org
Fri Feb 27 18:23:17 CET 2009


New submission from Hirokazu Yamamoto <ocean-city at 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 <report at bugs.python.org>
<http://bugs.python.org/issue5384>
_______________________________________


More information about the Python-bugs-list mailing list