anydbm - a simple question

Randall Hopper aa8vb at yahoo.com
Mon Jan 24 11:23:20 EST 2000


Andrew M. Kuchling:
 |Randall Hopper <aa8vb at yahoo.com> writes:
 |>  File "/home/rhh/software/python-1.5.2/lib/python1.5/dumbdbm.py", line 87,\
 |>    in _addval
 |>    f.write('\0'*(npos-pos))
 |>TypeError: can't multiply sequence with non-int
 |
 |I'll bet you're on Solaris and are picking up the large file support,
 |which makes the .tell() method of file objects return a long integer.
 |But you can't multiply a sequence by a long integer, only a regular
 |integer:
...
 |Short-term, you can patch dumbdbm.py to use int(npos-pos), but this is
 |really an interpreter bug; there's no reason 2L * 'a' should be an
 |error.

Ok, patching around this bug as you suggested, Fredrik's anydbm example
still fails.

   >>> import anydbm
   >>> db = anydbm.open( "database", "c" )
   >>> db[ "1" ] = "one"
   >>> db.close()
   >>> db = anydbm.open( "database", "r" )
   Traceback (innermost last):
     File "<stdin>", line 1, in ?
     File "/home/rhh/software/python-1.5.2/lib/python1.5/anydbm.py", line 80, in open
       raise error, "need 'c' or 'n' flag to open new db"
   anydbm.error: need 'c' or 'n' flag to open new db


It created the database.dir and database.dat files in the write phase,
but the read phase fails on the open.

Thinking it might be extension related I tried changing the file-to-open
from "database" to "database.dat".  But no dice:

   anydbm.error: db type could not be determined

Same thing if I change the path to "database.dir".

Is there another bug at work here?  Or is the example flawed?

-- 
Randall Hopper
aa8vb at yahoo.com




More information about the Python-list mailing list