[ python-Bugs-523425 ] shelve update fails on " large"
entry
SourceForge.net
noreply at sourceforge.net
Tue Nov 30 00:07:21 CET 2004
Bugs item #523425, was opened at 2002-02-27 12:03
Message generated for change (Settings changed) made by facundobatista
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=523425&group_id=5470
Category: Python Library
Group: Python 2.2
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: j vickroy (jvickroy)
Assigned to: Nobody/Anonymous (nobody)
Summary: shelve update fails on "large" entry
Initial Comment:
Below is a Python script that demonstrates a possible
bug when using the shelve module for:
Python 2.2
MS Windows 2000 and 98
For 10k, shelve entries, the script works as expected,
but for 15k entries, an exception is raised
after "some" number of updates.
I first tried to attach the script but received an
error.
# begin script
"""
Demonstration of possible update bug using shelve
module for:
Python 2.2
MS Windows 2000 and 98
"""
__author__ = 'jim.vickroy at noaa.gov'
import shelve
def keys():
return [str(i) for i in range(100)]
def archive():
return shelve.open('d:/logs/test')
##note = 'x'*10000 # this works
note = 'x'*15000 # this fails with the following
exception
"""
Traceback (most recent call last):
File "C:\PYTHON22\lib\site-
packages\Pythonwin\pywin\framework\scriptutils.py",
line 301, in RunScript
exec codeObject in __main__.__dict__
File "D:\py_trials\shelve_test.py", line 42, in ?
File "D:\py_trials\shelve_test.py", line 23, in
update
db.close()
File "C:\PYTHON22\lib\shelve.py", line 77, in
__setitem__
self.dict[key] = f.getvalue()
error: (0, 'Error')
"""
def update():
db = archive()
for this in keys():
if db.has_key(this):
entry = db[this]
entry.append(note)
else:
entry = [note]
db[this] = entry
db.close()
def validate():
db = archive()
actual_keys = db.keys()
expected_keys = keys()
assert len(actual_keys) == len(expected_keys), 'expected %s -- got %s' % (len(expected_keys),
len(actual_keys))
for this in keys():
entry = db[this]
assert len(entry) == nbr_of_updates, 'expected %s -- got %s' %
(nbr_of_updates, len(entry))
db.close()
nbr_of_updates = 10
for i in range(nbr_of_updates):
update()
validate()
# end script
----------------------------------------------------------------------
Comment By: j vickroy (jvickroy)
Date: 2004-11-29 13:17
Message:
Logged In: YES
user_id=17213
this bug does not appear in the following Python version:
'2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit
(Intel)]'
----------------------------------------------------------------------
Comment By: Facundo Batista (facundobatista)
Date: 2004-11-24 22:51
Message:
Logged In: YES
user_id=752496
Actually, the script you sent is not failing in the way
you're saying. Seems to be another problem, probably in the
script: I have to guess where ident it.
If you post another test case, could it please be more
concise and attach it as a file to this bug?
Thank you!
----------------------------------------------------------------------
Comment By: Facundo Batista (facundobatista)
Date: 2004-11-24 22:51
Message:
Logged In: YES
user_id=752496
Please, could you verify if this problem persists in Python 2.3.4
or 2.4?
If yes, in which version? Can you provide a test case?
If the problem is solved, from which version?
Note that if you fail to answer in one month, I'll close this bug
as "Won't fix".
Thank you!
. Facundo
----------------------------------------------------------------------
Comment By: Brett Cannon (bcannon)
Date: 2003-05-16 22:28
Message:
Logged In: YES
user_id=357491
I actually get a failure with 2.3b1 under OS X at the first assert:
Traceback (most recent call last):
File "shelve_test.py", line 42, in ?
validate()
File "shelve_test.py", line 30, in validate
assert len(actual_keys) == len(expected_keys), 'expected %s -- got %s' %
(len(expected_keys),
AssertionError: expected 100 -- got 0
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=523425&group_id=5470
More information about the Python-bugs-list
mailing list