[Python-bugs-list] [ python-Bugs-827760 ] Bug in dbm - long strings in keys and values

SourceForge.net noreply at sourceforge.net
Fri Oct 24 18:30:50 EDT 2003


Bugs item #827760, was opened at 2003-10-21 13:05
Message generated for change (Settings changed) made by jdcrunchman
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=827760&group_id=5470

>Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
>Priority: 7
Submitted By: John Draper (jdcrunchman)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bug in dbm - long strings in keys and values

Initial Comment:
#!/usr/local/bin/python
#2003-10-19. Feedback to crunch at shopip.com
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).
"""

mdb=dbm.open("mdb","n")
print "Writing 1 item to database, but upon reading,"
k='k'
v='X'*61230 #Long string
mdb[k]=v
mdb.close()

md=dbm.open("mdb","r")
print "database contains %i items"%len(md.keys())
md.close()

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=827760&group_id=5470



More information about the Python-bugs-list mailing list