Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 124a0b3

Browse files
Issue #19287: Fixed the "in" operator of dbm.ndbm databases for string
argument. Original patch by Arfrever Frehtes Taifersar Arahesis.
2 parents 7cb11fa + 9da33ab commit 124a0b3

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

Lib/test/test_dbm_ndbm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def test_keys(self):
2424
self.d[b'bytes'] = b'data'
2525
self.d['12345678910'] = '019237410982340912840198242'
2626
self.d.keys()
27+
self.assertIn('a', self.d)
2728
self.assertIn(b'a', self.d)
2829
self.assertEqual(self.d[b'bytes'], b'data')
2930
self.d.close()

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Projected release date: 2013-11-24
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #19287: Fixed the "in" operator of dbm.ndbm databases for string
14+
argument. Original patch by Arfrever Frehtes Taifersar Arahesis.
15+
1316
- Issue #19369: Optimized the usage of __length_hint__().
1417

1518
- Issue #18603: Ensure that PyOS_mystricmp and PyOS_mystrnicmp are in the

Modules/_dbmmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,9 @@ dbm_contains(PyObject *self, PyObject *arg)
221221
if (key.dptr == NULL)
222222
return -1;
223223
}
224-
if (!PyBytes_Check(arg)) {
224+
else if (!PyBytes_Check(arg)) {
225225
PyErr_Format(PyExc_TypeError,
226-
"dbm key must be string, not %.100s",
226+
"dbm key must be bytes or string, not %.100s",
227227
arg->ob_type->tp_name);
228228
return -1;
229229
}

0 commit comments

Comments
 (0)