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

Open shelves fail when Python exits #51181

Closed
lehmannro mannequin opened this issue Sep 17, 2009 · 2 comments
Closed

Open shelves fail when Python exits #51181

lehmannro mannequin opened this issue Sep 17, 2009 · 2 comments
Assignees
Labels
docs Documentation in the Doc dir extension-modules C modules in the Modules dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@lehmannro
Copy link
Mannequin

lehmannro mannequin commented Sep 17, 2009

BPO 6932
Nosy @birkenfeld
Files
  • example.py: minimal example reproducing the error
  • shelve-warning.patch: patch to Doc/library/shelve.rst, trunk
  • 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/birkenfeld'
    closed_at = <Date 2009-09-17.16:16:19.732>
    created_at = <Date 2009-09-17.15:55:56.272>
    labels = ['extension-modules', 'type-bug', 'library', 'docs']
    title = 'Open shelves fail when Python exits'
    updated_at = <Date 2009-09-17.16:16:19.731>
    user = 'https://bugs.python.org/lehmannro'

    bugs.python.org fields:

    activity = <Date 2009-09-17.16:16:19.731>
    actor = 'georg.brandl'
    assignee = 'georg.brandl'
    closed = True
    closed_date = <Date 2009-09-17.16:16:19.732>
    closer = 'georg.brandl'
    components = ['Documentation', 'Extension Modules', 'Library (Lib)']
    creation = <Date 2009-09-17.15:55:56.272>
    creator = 'lehmannro'
    dependencies = []
    files = ['14912', '14913']
    hgrepos = []
    issue_num = 6932
    keywords = ['patch']
    message_count = 2.0
    messages = ['92773', '92776']
    nosy_count = 2.0
    nosy_names = ['georg.brandl', 'lehmannro']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue6932'
    versions = ['Python 3.1', 'Python 2.7']

    @lehmannro
    Copy link
    Mannequin Author

    lehmannro mannequin commented Sep 17, 2009

    I'm reopening bpo-5483 by Zhigang Wang (zhigang) as a separate bug.

    Shelves that are still open when Python terminates will try to sync. If
    writeback=True, this pickles cached items.

    In this example, serialization of Test() re-imports __main__, which is
    already gc'd, and raises:
    Exception cPickle.PicklingError: Can't pickle <class '__main__.Test'>:
    it's not the same object as __main__.Test" in <bound method
    Shelf.__del__ of {'a': <main.Test object at 0x...>}>

    The error is ignored (due to Python already tearing down) but all cached
    modifications are lost.
    The promise "[t]he __del__() method of the Shelf class calls the close()
    method, so the programmer generally need not do this explicitly" is not
    true with writeback enabled.

    I'm unsure if this error can be fixed (probably with atexit/weakref, but
    that's more trouble than gain). I attached a patch to the docs simply
    warning the user of this issue (+ documenting Shelf.close, + removing
    above quote).

    @lehmannro lehmannro mannequin assigned birkenfeld Sep 17, 2009
    @lehmannro lehmannro mannequin added docs Documentation in the Doc dir extension-modules C modules in the Modules dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 17, 2009
    @birkenfeld
    Copy link
    Member

    Fixed docs (a bit differently) in r74876.

    @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
    docs Documentation in the Doc dir extension-modules C modules in the Modules dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant