summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-10-24 20:59:28 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-10-24 20:59:28 (GMT)
commit9da33ab193803922141f654f6d3cccdaed6b4866 (patch)
tree316dbe92a8e6cb7a74a0c84c8e90cf00550b582c
parentbe80fc9a843e3c51d1030d3eab52d6287e5aef3a (diff)
downloadcpython-9da33ab193803922141f654f6d3cccdaed6b4866.zip
cpython-9da33ab193803922141f654f6d3cccdaed6b4866.tar.gz
cpython-9da33ab193803922141f654f6d3cccdaed6b4866.tar.bz2
Issue #19287: Fixed the "in" operator of dbm.ndbm databases for string
argument. Original patch by Arfrever Frehtes Taifersar Arahesis.
-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 f9d3bef..b57e1f0 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 c05bffc..b43fa9a 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -81,6 +81,9 @@ Core and Builtins
Library
-------
+- Issue #19287: Fixed the "in" operator of dbm.ndbm databases for string
+ argument. Original patch by Arfrever Frehtes Taifersar Arahesis.
+
- Issue #19327: Fixed the working of regular expressions with too big charset.
- Issue #19350: Increasing the test coverage of macurl2path. Patch by Colin
diff --git a/Modules/_dbmmodule.c b/Modules/_dbmmodule.c
index 327b873..83c051c 100644
--- a/Modules/_dbmmodule.c
+++ b/Modules/_dbmmodule.c
@@ -225,9 +225,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;
}