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

operations on closed shelves fail cryptically #45933

Closed
erno mannequin opened this issue Dec 11, 2007 · 7 comments
Closed

operations on closed shelves fail cryptically #45933

erno mannequin opened this issue Dec 11, 2007 · 7 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@erno
Copy link
Mannequin

erno mannequin commented Dec 11, 2007

BPO 1592
Nosy @loewis, @rhettinger, @tebeka, @tiran
Files
  • shelve.diff
  • shelve.diff: Alternate patch
  • 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 2008-07-25.18:44:01.756>
    created_at = <Date 2007-12-11.18:38:16.861>
    labels = ['type-bug', 'library']
    title = 'operations on closed shelves fail cryptically'
    updated_at = <Date 2008-07-25.18:44:01.755>
    user = 'https://bugs.python.org/erno'

    bugs.python.org fields:

    activity = <Date 2008-07-25.18:44:01.755>
    actor = 'rhettinger'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2008-07-25.18:44:01.756>
    closer = 'rhettinger'
    components = ['Library (Lib)']
    creation = <Date 2007-12-11.18:38:16.861>
    creator = 'erno'
    dependencies = []
    files = ['8930', '10981']
    hgrepos = []
    issue_num = 1592
    keywords = ['patch']
    message_count = 7.0
    messages = ['58453', '58463', '58490', '70257', '70261', '70265', '70268']
    nosy_count = 5.0
    nosy_names = ['loewis', 'rhettinger', 'tebeka', 'christian.heimes', 'erno']
    pr_nums = []
    priority = 'low'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue1592'
    versions = ['Python 2.6', 'Python 3.0']

    @erno
    Copy link
    Mannequin Author

    erno mannequin commented Dec 11, 2007

    shelve objects set self.dict = 0 in their close() method. this
    results in errors such as TypeError: unsubscriptable object and
    AttributeError: 'int' object has no attribute 'has_key'.
    This is fairly baffling for the user.

    "self.dict = 0" in close() is present in current svn trunk too.

    @erno erno mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Dec 11, 2007
    @tiran
    Copy link
    Member

    tiran commented Dec 11, 2007

    Can you create a patch? I suggest to use self.dict = None as marker for
    a closed shelf.

    @erno
    Copy link
    Mannequin Author

    erno mannequin commented Dec 12, 2007

    How about the following patch. With it, you get an IOError.

    >>> s = shelve.open('/tmp/t', 'c')
    >>> s.has_key('foo')
    0
    >>> s.close()
    >>> s.has_key('foo')
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File "shelve.py", line 107, in has_key
        return self.dict.has_key(key)
      File "shelve.py", line 94, in getdict
        raise IOError, 'shelf has been closed'
    IOError: shelf has been closed

    @tebeka
    Copy link
    Mannequin

    tebeka mannequin commented Jul 25, 2008

    Any reason this is not in trunk yet?

    @rhettinger rhettinger self-assigned this Jul 25, 2008
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Jul 25, 2008

    The usual reasons, probably: nobody had time to work on it, as there are
    so many other things to do.

    @rhettinger
    Copy link
    Contributor

    I'm working on this one. Alternate patch attached.

    The problem with the old one is that it slows down every access to the
    shelf and it prevents assignment to self.dict which has always been
    allowed.

    The new patch improves error reporting without changing performance or
    semantics for shelves prior to closing.

    @rhettinger
    Copy link
    Contributor

    Fixed in r65233

    @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 type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants