summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xLib/test/test_dbm_ndbm.py1
-rw-r--r--Misc/NEWS3
-rw-r--r--Modules/_dbmmodule.c4
3 files changed, 6 insertions, 2 deletions
diff --git a/Lib/test/test_dbm_ndbm.py b/Lib/test/test_dbm_ndbm.py
index f9d3befde9..b57e1f0653 100755
--- a/Lib/test/test_dbm_ndbm.py
+++ b/Lib/test/test_dbm_ndbm.py
@@ -24,6 +24,7 @@ class DbmTestCase(unittest.TestCase):
self.d[b'bytes'] = b'data'
self.d['12345678910'] = '019237410982340912840198242'
self.d.keys()
+ self.assertIn('a', self.d)
self.assertIn(b'a', self.d)
self.assertEqual(self.d[b'bytes'], b'data')
self.d.close()
diff --git a/Misc/NEWS b/Misc/NEWS
index 52c86907f4..9f9ed65975 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ Projected release date: 2013-11-24
Core and Builtins
-----------------
+- Issue #19287: Fixed the "in" operator of dbm.ndbm databases for string
+ argument. Original patch by Arfrever Frehtes Taifersar Arahesis.
+
- Issue #19369: Optimized the usage of __length_hint__().
- Issue #18603: Ensure that PyOS_mystricmp and PyOS_mystrnicmp are in the
diff --git a/Modules/_dbmmodule.c b/Modules/_dbmmodule.c
index 8babd0eb15..60802b694a 100644
--- a/Modules/_dbmmodule.c
+++ b/Modules/_dbmmodule.c
@@ -221,9 +221,9 @@ dbm_contains(PyObject *self, PyObject *arg)
if (key.dptr == NULL)
return -1;
}
- if (!PyBytes_Check(arg)) {
+ else if (!PyBytes_Check(arg)) {
PyErr_Format(PyExc_TypeError,
- "dbm key must be string, not %.100s",
+ "dbm key must be bytes or string, not %.100s",
arg->ob_type->tp_name);
return -1;
}