[New-bugs-announce] [issue3799] Byte/string inconsistencies between different dbm modules

Skip Montanaro report at bugs.python.org
Sat Sep 6 23:59:32 CEST 2008


New submission from Skip Montanaro <skip at pobox.com>:

Consider these two timeit commands:

py3k% python3.0 -m timeit -s 'import dbm.ndbm as db' -s 'f = 
db.open("/tmp/trash.db", "c")' 'for i in range(1000): f[str(i)] = str(i)'
100 loops, best of 3: 5.51 msec per loop
py3k% python3.0 -m timeit -s 'import dbm.dumb as db' -s 'f = 
db.open("/tmp/trash.db", "c")' 'for i in range(1000): f[str(i)] = str(i)'
Traceback (most recent call last):
  File "/Users/skip/local/lib/python3.0/timeit.py", line 297, in main
    x = t.timeit(number)
  File "/Users/skip/local/lib/python3.0/timeit.py", line 193, in timeit
    timing = self.inner(it, self.timer)
  File "<timeit-src>", line 7, in inner
    for i in range(1000): f[str(i)] = str(i)
  File "/Users/skip/local/lib/python3.0/dbm/dumb.py", line 165, in 
__setitem__
    raise TypeError("keys must be bytes")
TypeError: keys must be bytes

Seems to me they should either both succeed or both fail.  What are keys
and values supposed to be for these modules?

Marking it as high priority.  When 3.0 is released all these modules
should probably agree.

----------
messages: 72711
nosy: skip.montanaro
priority: high
severity: normal
status: open
title: Byte/string inconsistencies between different dbm modules
type: behavior
versions: Python 3.0

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


More information about the New-bugs-announce mailing list