[Python-checkins] cpython (merge 3.3 -> default): Issue #19287: Fixed the "in" operator of dbm.ndbm databases for string

serhiy.storchaka python-checkins at python.org
Thu Oct 24 23:02:17 CEST 2013


http://hg.python.org/cpython/rev/cb82b4efa67b
changeset:   86605:cb82b4efa67b
parent:      86603:8939c0196990
parent:      86604:61ab0c6907f9
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Fri Oct 25 00:01:25 2013 +0300
summary:
  Issue #19287: Fixed the "in" operator of dbm.ndbm databases for string
argument.  Original patch by Arfrever Frehtes Taifersar Arahesis.

files:
  Lib/test/test_dbm_ndbm.py |  1 +
  Misc/NEWS                 |  3 +++
  Modules/_dbmmodule.c      |  4 ++--
  3 files changed, 6 insertions(+), 2 deletions(-)


diff --git a/Lib/test/test_dbm_ndbm.py b/Lib/test/test_dbm_ndbm.py
--- a/Lib/test/test_dbm_ndbm.py
+++ b/Lib/test/test_dbm_ndbm.py
@@ -24,6 +24,7 @@
         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
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
 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
--- a/Modules/_dbmmodule.c
+++ b/Modules/_dbmmodule.c
@@ -221,9 +221,9 @@
         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;
     }

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list