Issue 2112. mmap does not raises EnvironmentError no more, but
authorFacundo Batista <facundobatista@gmail.com>
Sun, 17 Feb 2008 18:59:29 +0000 (18:59 +0000)
committerFacundo Batista <facundobatista@gmail.com>
Sun, 17 Feb 2008 18:59:29 +0000 (18:59 +0000)
a subclass of it. Thanks John Lenton.

Lib/test/test_mmap.py
Misc/NEWS
Modules/mmapmodule.c

index 8a145cfddbaff802105f6393b4a8ac6df1d6e9c1..49ec78b842d906769a8bd41bee8fef2920da7c15 100644 (file)
@@ -436,6 +436,11 @@ class MmapTests(unittest.TestCase):
         self.assertRaises(TypeError, m.write, "foo")
 
 
+    def test_error(self):
+        self.assert_(issubclass(mmap.error, EnvironmentError))
+        self.assert_("mmap.error" in str(mmap.error))
+
+
 def test_main():
     run_unittest(MmapTests)
 
index 377f1ed29279238e9d9d0cbb58b907c040c2f689..a722195c52c38bdbf3a57c174d9ab220c7513ba0 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -1149,6 +1149,9 @@ Library
 Extension Modules
 -----------------
 
+- #2112: mmap.error is now a subclass of EnvironmentError and not a
+  direct EnvironmentError
+
 - Bug #2111: mmap segfaults when trying to write a block opened with PROT_READ
 
 - #2063: correct order of utime and stime in os.times() result on Windows.
index e47211f171a20ebbd03f8cc47f26c667da8ebfba..c71d8402cbd495ea6ce7eadcf1143a971d8c8efd 100644 (file)
@@ -1402,7 +1402,10 @@ initmmap(void)
        dict = PyModule_GetDict(module);
        if (!dict)
                return;
-       mmap_module_error = PyExc_EnvironmentError;
+       mmap_module_error = PyErr_NewException("mmap.error",
+               PyExc_EnvironmentError , NULL);
+       if (mmap_module_error == NULL)
+               return;
        PyDict_SetItemString(dict, "error", mmap_module_error);
        PyDict_SetItemString(dict, "mmap", (PyObject*) &mmap_object_type);
 #ifdef PROT_EXEC