Issue 19287: contains() of dbm.ndbm databases fails with str (original) (raw)
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 "", line 1, in 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 "", line 1, in 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".