From: Moshe Zadka Date: Sat, 31 Mar 2001 13:23:19 +0000 (+0000) Subject: - #128713 - mmapmodule.c - type(mmap_object) blew up on Linux. X-Git-Tag: v2.0.1c1~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b219694a2682a13854790a7c1de566b922a68b2;p=thirdparty%2FPython%2Fcpython.git - #128713 - mmapmodule.c - type(mmap_object) blew up on Linux. - mmap on windows creates a mapping without a name when tagname isn't specified --- diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index b245c895d6e5..36bc4b709f40 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -841,9 +841,6 @@ new_mmap_object(PyObject *self, PyObject *args) int fileno; HANDLE fh = 0; - /* Patch the object type */ - mmap_object_type.ob_type = &PyType_Type; - if (!PyArg_ParseTuple(args, "iO|z", &fileno, @@ -907,7 +904,7 @@ new_mmap_object(PyObject *self, PyObject *args) m_obj->pos = (size_t) 0; /* set the tag name */ - if (tagname != NULL) { + if (tagname != NULL && *tagname != '\0') { m_obj->tagname = PyMem_Malloc(strlen(tagname)+1); if (m_obj->tagname == NULL) { PyErr_NoMemory(); @@ -924,7 +921,7 @@ new_mmap_object(PyObject *self, PyObject *args) PAGE_READWRITE, 0, m_obj->size, - tagname); + m_obj->tagname); if (m_obj->map_handle != NULL) { m_obj->data = (char *) MapViewOfFile (m_obj->map_handle, FILE_MAP_WRITE, @@ -962,6 +959,10 @@ extern void initmmap(void) { PyObject *dict, *module; + + /* Patch the object type */ + mmap_object_type.ob_type = &PyType_Type; + module = Py_InitModule ("mmap", mmap_functions); dict = PyModule_GetDict (module); mmap_module_error = PyExc_EnvironmentError;