]> granicus.if.org Git - python/commitdiff
#3929: dbm.open() would try to raise a tuple. This does not work anymore with python...
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Thu, 25 Sep 2008 22:27:43 +0000 (22:27 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Thu, 25 Sep 2008 22:27:43 +0000 (22:27 +0000)
Reviewed by Georg Brandl.

Lib/dbm/__init__.py
Lib/test/test_dbm.py
Misc/NEWS

index 2082e07335705f29fc7d4ea85af0f9dfa03e84e3..19a7072628c3d2219127e072f3ffebf643923061 100644 (file)
@@ -76,13 +76,13 @@ def open(file, flag = 'r', mode = 0o666):
             # file doesn't exist and the new flag was used so use default type
             mod = _defaultmod
         else:
-            raise error("need 'c' or 'n' flag to open new db")
+            raise error[0]("need 'c' or 'n' flag to open new db")
     elif result == "":
         # db type cannot be determined
-        raise error("db type could not be determined")
+        raise error[0]("db type could not be determined")
     elif result not in _modules:
-        raise error("db type is {0}, but the module is not "
-                    "available".format(result))
+        raise error[0]("db type is {0}, but the module is not "
+                       "available".format(result))
     else:
         mod = _modules[result]
     return mod.open(file, flag, mode)
index 41c37cbea515bee9407f58c6a45bc1320e7f8aae..ee82dd2fa90ecdd48f5896ec0e056b6043167c60 100644 (file)
@@ -57,6 +57,9 @@ class AnyDBMTestCase(unittest.TestCase):
     def test_error(self):
         self.assert_(issubclass(self.module.error, IOError))
 
+    def test_anydbm_not_existing(self):
+        self.assertRaises(dbm.error, dbm.open, _fname)
+
     def test_anydbm_creation(self):
         f = dbm.open(_fname, 'c')
         self.assertEqual(list(f.keys()), [])
index c1ab3d381d4b34c7f430337610c658212f0c2c87..36240edcf3c8010f4e76f73956eec0db7df71b6b 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -20,6 +20,10 @@ Core and Builtins
 Library
 -------
 
+- Issue #3929: When the database cannot be opened, dbm.open() would incorrectly
+  raise a TypeError: "'tuple' object is not callable" instead of the expected
+  dbm.error.
+
 - Bug #3884: Make the turtle module toplevel again.
 
 - Issue #3547: Fixed ctypes structures bitfields of varying integer