Wednesday, September 20, 2006

Interesting discover about pys60 v1.3.1

To store a list of names in the database against a key, I use marshal.dumps(list). I got an interesting error while doing this:

len(l)
128
>>> db['check'] = marshal.dumps(l)
Traceback (most recent call last):
File "", line 1, in ?
File "C:\system\libs\e32dbm.py", line 145, in __setitem__
self._dbset(key,value)
File "C:\system\libs\e32dbm.py", line 100, in _dbset
self._execute(u"INSERT INTO data VALUES (%d,'%s','%s')"% (hash(key),sqlquote(key),sqlquote(value)))
UnicodeError: ASCII decoding error: ordinal not in range(128)


If the length of the list is 127, it stores fine in the database. Strange, huh? No! Doing, a db['check'] = unicode(marshal.dumps()) doesn't work either.

Workaround?
db['check'] = ';'.join(list)
list = db['check'].split(';')

2 comments:

cyke64 said...

Send your bug to
http://sourceforge.net/project/shownotes.php?release_id=454317&group_id=154155

Broadband Sue said...

We all know that broadband suppliers advertise their speeds as "up to"
a certain level. But how fast is your actual connection? Now you can
find out with our broadbandspeed test, use the
checker below to find out. To get accurate results make sure that you
are not using your internet connection for anything else while the test
runs (it only takes a few seconds)