]> granicus.if.org Git - python/commitdiff
Issue #19287: Fixed the "in" operator of dbm.ndbm databases for string
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 24 Oct 2013 20:59:28 +0000 (23:59 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Thu, 24 Oct 2013 20:59:28 +0000 (23:59 +0300)
argument.  Original patch by Arfrever Frehtes Taifersar Arahesis.

Lib/test/test_dbm_ndbm.py
Misc/NEWS
Modules/_dbmmodule.c

index f9d3befde9824674cdfaa0605b489e0998945f2c..b57e1f0653573b8bbb3e7d63431c39ad516b562c 100755 (executable)
@@ -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()
index c05bffc882d3d62deca8e177dffda73ffc3c8ed8..b43fa9a058b05b34cb9233a657ab6439405eb84c 100644 (file)
--- 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
index 327b8730c20331e5503a7453e3b7f52738af15ee..83c051c505e21fe4c43c2db776f9187fcfec56b6 100644 (file)
@@ -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;
     }