Index: Lib/dbm/__init__.py =================================================================== --- Lib/dbm/__init__.py (revision 66515) +++ Lib/dbm/__init__.py (working copy) @@ -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) Index: Lib/test/test_dbm.py =================================================================== --- Lib/test/test_dbm.py (revision 66515) +++ Lib/test/test_dbm.py (working copy) @@ -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()), [])