This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: __contains__() of dbm.ndbm databases fails with str
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Arfrever, berker.peksag, georg.brandl, larry, loewis, python-dev, serhiy.storchaka, vajrasky
Priority: normal Keywords: 3.3regression, easy, patch

Created on 2013-10-18 19:57 by Arfrever, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue19287.patch Arfrever, 2013-10-19 04:33 review
Messages (7)
msg200303 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) Date: 2013-10-18 19:57
__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".
msg200396 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-10-19 10:21
What about dbm.gnu and dbm.dumb? Should we add string key support as well?
msg200398 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-10-19 10:28
Sorry, I just found out that you already created a separate ticket for dbm.gnu.

http://bugs.python.org/issue19288

What about dbm.dumb?
msg200403 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2013-10-19 11:16
> What about dbm.dumb?

dbm.dumb works fine with str:

$ python3.3 -c 'from dbm import dumb; db=dumb.open("/tmp/db2", "c"); db["key"]="value"; print(b"key" in db); print("key" in db)'
True
True

$ ./python -c 'from dbm import dumb; db=dumb.open("/tmp/db2", "c"); db["key"]="value"; print(b"key" in db); print("key" in db)'
True
True

http://hg.python.org/cpython/file/47618b00405b/Lib/dbm/dumb.py#l217
msg200818 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-10-21 18:20
LGTM. Could you please sign a contributor agreement ([1], [2]) Arfrever?

[1] http://www.python.org/psf/contrib/
[2] http://www.python.org/psf/contrib/contrib-form/
msg201186 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-10-24 21:02
New changeset 61ab0c6907f9 by Serhiy Storchaka in branch '3.3':
Issue #19287: Fixed the "in" operator of dbm.ndbm databases for string
http://hg.python.org/cpython/rev/61ab0c6907f9

New changeset cb82b4efa67b by Serhiy Storchaka in branch 'default':
Issue #19287: Fixed the "in" operator of dbm.ndbm databases for string
http://hg.python.org/cpython/rev/cb82b4efa67b
msg201188 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-10-24 21:10
Thank you for your contribution Arfrever.
History
Date User Action Args
2022-04-11 14:57:52adminsetgithub: 63486
2013-10-24 21:10:31serhiy.storchakasetstatus: open -> closed
type: behavior
messages: + msg201188

resolution: fixed
stage: patch review -> resolved
2013-10-24 21:02:36python-devsetnosy: + python-dev
messages: + msg201186
2013-10-21 18:20:39serhiy.storchakasetpriority: release blocker -> normal

nosy: + serhiy.storchaka
messages: + msg200818

assignee: serhiy.storchaka
2013-10-19 20:45:23Arfreversetpriority: normal -> release blocker
nosy: + larry, georg.brandl
2013-10-19 11:16:17berker.peksagsetnosy: + berker.peksag
messages: + msg200403
2013-10-19 10:28:13vajraskysetmessages: + msg200398
2013-10-19 10:21:58vajraskysetnosy: + vajrasky
messages: + msg200396
2013-10-19 04:34:56Arfreversetkeywords: + easy
stage: patch review
2013-10-19 04:33:56Arfreversetfiles: + issue19287.patch
keywords: + patch
2013-10-18 19:57:22Arfrevercreate