diff options
Diffstat (limited to 'Modules/mmapmodule.c')
-rw-r--r-- | Modules/mmapmodule.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index f4a80c2..35d61ba 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -78,8 +78,6 @@ my_getpagesize(void) # define MAP_ANONYMOUS MAP_ANON #endif -static PyObject *mmap_module_error; - typedef enum { ACCESS_DEFAULT, @@ -459,7 +457,7 @@ mmap_size_method(mmap_object *self, { struct stat buf; if (-1 == fstat(self->fd, &buf)) { - PyErr_SetFromErrno(mmap_module_error); + PyErr_SetFromErrno(PyExc_OSError); return NULL; } #ifdef HAVE_LARGEFILE_SUPPORT @@ -549,7 +547,7 @@ mmap_resize_method(mmap_object *self, void *newmap; if (ftruncate(self->fd, self->offset + new_size) == -1) { - PyErr_SetFromErrno(mmap_module_error); + PyErr_SetFromErrno(PyExc_OSError); return NULL; } @@ -564,7 +562,7 @@ mmap_resize_method(mmap_object *self, #endif if (newmap == (void *)-1) { - PyErr_SetFromErrno(mmap_module_error); + PyErr_SetFromErrno(PyExc_OSError); return NULL; } self->data = newmap; @@ -605,7 +603,7 @@ mmap_flush_method(mmap_object *self, PyObject *args) /* XXX semantics of return value? */ /* XXX flags for msync? */ if (-1 == msync(self->data + offset, size, MS_SYNC)) { - PyErr_SetFromErrno(mmap_module_error); + PyErr_SetFromErrno(PyExc_OSError); return NULL; } return PyLong_FromLong(0); @@ -1205,7 +1203,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict) fd = devzero = open("/dev/zero", O_RDWR); if (devzero == -1) { Py_DECREF(m_obj); - PyErr_SetFromErrno(mmap_module_error); + PyErr_SetFromErrno(PyExc_OSError); return NULL; } #endif @@ -1213,7 +1211,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict) m_obj->fd = dup(fd); if (m_obj->fd == -1) { Py_DECREF(m_obj); - PyErr_SetFromErrno(mmap_module_error); + PyErr_SetFromErrno(PyExc_OSError); return NULL; } } @@ -1229,7 +1227,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict) if (m_obj->data == (char *)-1) { m_obj->data = NULL; Py_DECREF(m_obj); - PyErr_SetFromErrno(mmap_module_error); + PyErr_SetFromErrno(PyExc_OSError); return NULL; } m_obj->access = (access_mode)access; @@ -1310,12 +1308,12 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict) if (fileno != -1 && fileno != 0) { /* Ensure that fileno is within the CRT's valid range */ if (_PyVerify_fd(fileno) == 0) { - PyErr_SetFromErrno(mmap_module_error); + PyErr_SetFromErrno(PyExc_OSError); return NULL; } fh = (HANDLE)_get_osfhandle(fileno); if (fh==(HANDLE)-1) { - PyErr_SetFromErrno(mmap_module_error); + PyErr_SetFromErrno(PyExc_OSError); return NULL; } /* Win9x appears to need us seeked to zero */ @@ -1469,11 +1467,7 @@ PyInit_mmap(void) dict = PyModule_GetDict(module); if (!dict) return NULL; - mmap_module_error = PyErr_NewException("mmap.error", - PyExc_EnvironmentError , NULL); - if (mmap_module_error == NULL) - return NULL; - PyDict_SetItemString(dict, "error", mmap_module_error); + PyDict_SetItemString(dict, "error", PyExc_OSError); PyDict_SetItemString(dict, "mmap", (PyObject*) &mmap_object_type); #ifdef PROT_EXEC setint(dict, "PROT_EXEC", PROT_EXEC); |