Bugs item #1339007, was opened at 2005-10-27 01:30
Message generated for change (Comment added) made by birkenfeld
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1339007&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Geoffrey T. Dairiki (dairiki)
>Assigned to: Raymond Hettinger (rhettinger)
Summary: shelve.Shelf.__del__ throws exceptions

Initial Comment:
Python calls an object's __del__ method, even if the
objects __init__ method was unsuccessful (i.e. __init__
terminated via exception.)

Because of this, if there is an error while attempting
to open a Shelf, the destructor is still called, even
though the Shelf is not fully constructed.  The code in
shelve.Shelf does not check for this possibility, and
therefor triggers an AttributeError.

Here is an example script which should reproduce the error.

===Begin test.py====l
import shelve
try:
    shelf = shelve.open('non-existant-file', flag='r')
except:
    pass
===End test.py=====

For me, the above script produces the message:

Exception exceptions.AttributeError: "DbfilenameShelf
instance has no attribute 'writeback'" in  ignored

I can reproduce this using either Python 2.4.1 or
2.3.5.  I took a quick look at the current CVS version
of shelve.py, and it appears to suffer the same problem.







----------------------------------------------------------------------

>Comment By: Georg Brandl (birkenfeld)
Date: 2006-01-20 23:10

Message:
Logged In: YES 
user_id=1188172

Is this a bug? As exceptions in __del__ are ignored, this
should do no harm.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1339007&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to