Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shelve.Shelf.__del__ throws exceptions #42527

Closed
dairiki mannequin opened this issue Oct 26, 2005 · 4 comments
Closed

shelve.Shelf.__del__ throws exceptions #42527

dairiki mannequin opened this issue Oct 26, 2005 · 4 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@dairiki
Copy link
Mannequin

dairiki mannequin commented Oct 26, 2005

BPO 1339007
Nosy @birkenfeld, @birkenfeld, @rhettinger

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/rhettinger'
closed_at = <Date 2006-06-14.06:09:28.000>
created_at = <Date 2005-10-26.23:30:42.000>
labels = ['library']
title = 'shelve.Shelf.__del__ throws exceptions'
updated_at = <Date 2006-06-14.06:09:28.000>
user = 'https://bugs.python.org/dairiki'

bugs.python.org fields:

activity = <Date 2006-06-14.06:09:28.000>
actor = 'georg.brandl'
assignee = 'rhettinger'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2005-10-26.23:30:42.000>
creator = 'dairiki'
dependencies = []
files = []
hgrepos = []
issue_num = 1339007
keywords = []
message_count = 4.0
messages = ['26742', '26743', '26744', '26745']
nosy_count = 4.0
nosy_names = ['georg.brandl', 'georg.brandl', 'rhettinger', 'dairiki']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1339007'
versions = []

@dairiki
Copy link
Mannequin Author

dairiki mannequin commented Oct 26, 2005

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.

@dairiki dairiki mannequin closed this as completed Oct 26, 2005
@dairiki dairiki mannequin assigned rhettinger Oct 26, 2005
@dairiki dairiki mannequin added the stdlib Python modules in the Lib dir label Oct 26, 2005
@dairiki dairiki mannequin closed this as completed Oct 26, 2005
@dairiki dairiki mannequin assigned rhettinger Oct 26, 2005
@dairiki dairiki mannequin added the stdlib Python modules in the Lib dir label Oct 26, 2005
@birkenfeld
Copy link
Member

Logged In: YES
user_id=1188172

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

@dairiki
Copy link
Mannequin Author

dairiki mannequin commented Jan 25, 2006

Logged In: YES
user_id=45814

Exceptions thrown in __del__ are not quite complete ignored,
since the fact that they are being "ignored" is reported on
sys.stderr.

The bug in question results in spurious, confusing messages
being issued to sys.stderr. I say it is a bug.

@birkenfeld
Copy link
Member

Logged In: YES
user_id=849994

Fixed in rev. 46946, 46947 (2.4).

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

2 participants