[Python-Dev] dbm bugs?

John D. lists at webcrunchers.com
Mon Oct 20 14:46:17 EDT 2003

#2003-10-19. Feedback
import dbm

print """
Python dbm bugs summary:
  1. Long strings cause weirdness.
  2. Long keys fail without returning error.

This demonstrates serious bugs in the Python dbm module.
Present in OpenBSD versions 2.2, 2.3, and 2.3.2c1.

len(key+string)>61231 results in the item being 'lost', without warning.
If the key or string is one character shorter, it is fine.
Writing multiple long strings causes unpredictable results
(none, some, or all of the items are lost without warning).

Curiously, keys of length 57148 return an error, but
longer keys fail without warning
(sounds like an = instead of a > somewhere).

print "Writing 1 item to database, but upon reading,"
v='X'*61230 #Long string

print "database contains %i items"%len(md.keys())

More information about the Python-Dev mailing list