This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: shelve update fails on "large" entry
Type: Stage:
Components: Library (Lib) Versions: Python 2.2
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, facundobatista, jvickroy
Priority: normal Keywords:

Created on 2002-02-27 15:03 by jvickroy, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (5)
msg9445 - (view) Author: j vickroy (jvickroy) Date: 2002-02-27 15:03
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 

# begin script
Demonstration of possible update bug using shelve 
module for:
   Python 2.2
   MS Windows 2000 and 98

__author__ = ''

import shelve

def keys():
   return [str(i) for i in range(100)]

def archive():

##note = 'x'*10000 # this works 
note = 'x'*15000 # this fails with the following 
Traceback (most recent call last):
  File "C:\PYTHON22\lib\site-
line 301, in RunScript
    exec codeObject in __main__.__dict__
  File "D:\py_trials\", line 42, in ?
  File "D:\py_trials\", line 23, in 
  File "C:\PYTHON22\lib\", line 77, in 
    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 = [note]
      db[this] = entry

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), 
   for this in keys():
      entry = db[this]
      assert len(entry) == nbr_of_updates, \
             'expected %s -- got %s' % 
(nbr_of_updates, len(entry))

nbr_of_updates = 10
for i in range(nbr_of_updates):


# end script
msg9446 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2003-05-17 01:28
Logged In: YES 

I actually get a failure with 2.3b1 under OS X at the first assert:

Traceback (most recent call last):
  File "", line 42, in ?
  File "", line 30, in validate
    assert len(actual_keys) == len(expected_keys), 'expected %s -- got %s' % 
AssertionError: expected 100 -- got 0
msg9447 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2004-11-25 01:51
Logged In: YES 

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
msg9448 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2004-11-25 01:51
Logged In: YES 

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!
msg9449 - (view) Author: j vickroy (jvickroy) Date: 2004-11-29 16:17
Logged In: YES 

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 
Date User Action Args
2022-04-10 16:05:02adminsetgithub: 36176
2002-02-27 15:03:48jvickroycreate