When key is None, give up if _DB_get_type() returns -1 as well.
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c
index ba6af27..b9259d6 100644
--- a/Modules/_bsddb.c
+++ b/Modules/_bsddb.c
@@ -350,6 +350,8 @@
     CLEAR_DBT(*key);
     if (keyobj == Py_None) {  /* TODO: is None really okay for keys? */
         type = _DB_get_type(self);
+        if (type == -1)
+            return 0;
         if (type == DB_RECNO || type == DB_QUEUE) {
             PyErr_SetString(
                 PyExc_TypeError,