[Python-3000-checkins] r66622 - in python/branches/py3k: Lib/dbm/__init__.py Lib/test/test_dbm.py Misc/NEWS

amaury.forgeotdarc python-3000-checkins at python.org
Fri Sep 26 00:27:43 CEST 2008


Author: amaury.forgeotdarc
Date: Fri Sep 26 00:27:43 2008
New Revision: 66622

Log:
#3929: dbm.open() would try to raise a tuple.  This does not work anymore with python 3.0.

Reviewed by Georg Brandl.


Modified:
   python/branches/py3k/Lib/dbm/__init__.py
   python/branches/py3k/Lib/test/test_dbm.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/dbm/__init__.py
==============================================================================
--- python/branches/py3k/Lib/dbm/__init__.py	(original)
+++ python/branches/py3k/Lib/dbm/__init__.py	Fri Sep 26 00:27:43 2008
@@ -76,13 +76,13 @@
             # 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)

Modified: python/branches/py3k/Lib/test/test_dbm.py
==============================================================================
--- python/branches/py3k/Lib/test/test_dbm.py	(original)
+++ python/branches/py3k/Lib/test/test_dbm.py	Fri Sep 26 00:27:43 2008
@@ -57,6 +57,9 @@
     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()), [])

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Fri Sep 26 00:27:43 2008
@@ -20,6 +20,10 @@
 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


More information about the Python-3000-checkins mailing list