[Tutor] perplexing error with shelve REVISED

Aditya Lal aditya.n.lal at gmail.com
Wed Oct 31 08:43:12 CET 2007


On 10/31/07, Orest Kozyar <orest.kozyar at gmail.com> wrote:
>
> > Please post the entire traceback (omitting duplicate lines).
>
> Sorry, I should have included the traceback.  I've revised the sample
> script
> so that it generates the traceback when run.  The sample script is at the
> very bottom of this email.
>
> ####### SCRIPT OUTPUT #######
> [kozyar]:~$ python example.py
>
> Successfully retrieved and parsed XML document with ID 16842423
> Successfully shelved XML document with ID 16842423
> Successfully retrieved and parsed XML document with ID 16842422
>
> Traceback (most recent call last):
>   File "example.py", line 30, in <module>
>     data[badkey] = doc
>   File "/usr/lib64/python2.5/shelve.py", line 123, in __setitem__
>     p.dump(value)
>
> RuntimeError: maximum recursion depth exceeded
>
> Exception exceptions.RuntimeError: 'maximum recursion depth exceeded' in
> <bound method DbfilenameShelf.__del__ of {'16842423':
> <xml.dom.minidom.Document instance at 0x96f290>}> ignored
>
>
> ####### START SCRIPT #######
> import urllib, shelve
> from xml.dom import minidom
>
> baseurl = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?'
>
> params = {
>         'db':       'pubmed',
>         'retmode':  'xml',
>         'rettype':  'medline'
>         }
>
> badkey = '16842422'
> goodkey = '16842423' #or just about any other ID
>
> data = shelve.open('data.tmp', writeback=True)
>
> params['id'] = goodkey
> url = baseurl + urllib.urlencode(params)
> doc = minidom.parseString(urllib.urlopen(url).read())
> print 'Successfully retrieved and parsed XML document with ID %s' %
> goodkey
> data[goodkey] = doc
> print 'Successfully shelved XML document with ID %s' % goodkey
>
> params['id'] = badkey
> url = baseurl + urllib.urlencode(params)
> doc = minidom.parseString(urllib.urlopen(url).read())
> print 'Successfully retrieved and parsed XML document with ID %s' % badkey
> data[badkey] = doc
> #Will fail on the above line
> print 'Successfully shelved XML document with ID %s' % badkey
>
>
The program worked fine for me (python 2.5.1 - stackless on Mac OSX). Can
you provide details about your platform (python version, OS, etc.) ?
-- 
Aditya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071031/7abcd549/attachment.htm 


More information about the Tutor mailing list