summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Lib/bsddb/test/test_dbobj.py4
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/_bsddb.c2
3 files changed, 6 insertions, 2 deletions
diff --git a/Lib/bsddb/test/test_dbobj.py b/Lib/bsddb/test/test_dbobj.py
index 6799fc9c22..af494e19fd 100644
--- a/Lib/bsddb/test/test_dbobj.py
+++ b/Lib/bsddb/test/test_dbobj.py
@@ -69,6 +69,10 @@ class dbobjTestCase(unittest.TestCase):
self.db.close()
self.env.close()
+ def test03_dbobj_type_before_open(self):
+ # Ensure this doesn't cause a segfault.
+ self.assertRaises(db.DBInvalidArgError, db.DB().type)
+
#----------------------------------------------------------------------
def test_suite():
diff --git a/Misc/NEWS b/Misc/NEWS
index 28543f6f75..231004dc4a 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -276,6 +276,8 @@ Library
Extension Modules
-----------------
+- Bug #1599782: fix segfault on bsddb.db.DB().type().
+
- Fix bugs in ctypes:
- anonymous structure fields that have a bit-width specified did not work
- cast function did not accept c_char_p or c_wchar_p instances as first arg
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c
index 9d56e2765d..8e343a652e 100644
--- a/Modules/_bsddb.c
+++ b/Modules/_bsddb.c
@@ -1779,9 +1779,7 @@ DB_get_type(DBObject* self, PyObject* args)
return NULL;
CHECK_DB_NOT_CLOSED(self);
- MYDB_BEGIN_ALLOW_THREADS;
type = _DB_get_type(self);
- MYDB_END_ALLOW_THREADS;
if (type == -1)
return NULL;
return PyInt_FromLong(type);