Issue #19287: Fixed the "in" operator of dbm.ndbm databases for string

argument.  Original patch by Arfrever Frehtes Taifersar Arahesis.
This commit is contained in:
Serhiy Storchaka 2013-10-25 00:01:25 +03:00
commit 124a0b314b
3 changed files with 6 additions and 2 deletions

View File

@ -24,6 +24,7 @@ class DbmTestCase(unittest.TestCase):
self.d[b'bytes'] = b'data' self.d[b'bytes'] = b'data'
self.d['12345678910'] = '019237410982340912840198242' self.d['12345678910'] = '019237410982340912840198242'
self.d.keys() self.d.keys()
self.assertIn('a', self.d)
self.assertIn(b'a', self.d) self.assertIn(b'a', self.d)
self.assertEqual(self.d[b'bytes'], b'data') self.assertEqual(self.d[b'bytes'], b'data')
self.d.close() self.d.close()

View File

@ -10,6 +10,9 @@ Projected release date: 2013-11-24
Core and Builtins 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 #19369: Optimized the usage of __length_hint__().
- Issue #18603: Ensure that PyOS_mystricmp and PyOS_mystrnicmp are in the - Issue #18603: Ensure that PyOS_mystricmp and PyOS_mystrnicmp are in the

View File

@ -221,9 +221,9 @@ dbm_contains(PyObject *self, PyObject *arg)
if (key.dptr == NULL) if (key.dptr == NULL)
return -1; return -1;
} }
if (!PyBytes_Check(arg)) { else if (!PyBytes_Check(arg)) {
PyErr_Format(PyExc_TypeError, 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); arg->ob_type->tp_name);
return -1; return -1;
} }