[issue19287] __contains__() of dbm.ndbm databases fails with str

Arfrever Frehtes Taifersar Arahesis report at bugs.python.org
Fri Oct 18 21:57:22 CEST 2013


New submission from Arfrever Frehtes Taifersar Arahesis:

__contains__()  of dbm.ndbm databases fails with str, probably since 8beaa9a37387.
This is a regression in Python 3.3.

$ python3.2 -c 'import dbm.ndbm; db=dbm.ndbm.open("/tmp/db1", "c"); db["key"]="value"; print(b"key" in db); print("key" in db)'
True
True
$ python3.3 -c 'import dbm.ndbm; db=dbm.ndbm.open("/tmp/db2", "c"); db["key"]="value"; print(b"key" in db); print("key" in db)'
True
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: dbm key must be string, not str
$ python3.4 -c 'import dbm.ndbm; db=dbm.ndbm.open("/tmp/db3", "c"); db["key"]="value"; print(b"key" in db); print("key" in db)'
True
Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: dbm key must be string, not str


Also please improve error message to e.g. "dbm key must be bytes or string, not %.100s".

----------
components: Library (Lib)
keywords: 3.3regression
messages: 200303
nosy: Arfrever, loewis
priority: normal
severity: normal
status: open
title: __contains__()  of dbm.ndbm databases fails with str
versions: Python 3.3, Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19287>
_______________________________________


More information about the Python-bugs-list mailing list