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 references globals in its __del__ method #55849

Closed
PeterDavies mannequin opened this issue Mar 22, 2011 · 4 comments
Closed

Shelve references globals in its __del__ method #55849

PeterDavies mannequin opened this issue Mar 22, 2011 · 4 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@PeterDavies
Copy link
Mannequin

PeterDavies mannequin commented Mar 22, 2011

BPO 11640
Nosy @durban, @akheron, @berkerpeksag
Files
  • shelve_del_fix.diff: Fix which stores the globals in the shelf
  • 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 = None
    closed_at = <Date 2016-09-12.02:43:11.820>
    created_at = <Date 2011-03-22.22:15:42.956>
    labels = ['type-bug', 'library']
    title = 'Shelve references globals in its __del__ method'
    updated_at = <Date 2016-09-12.02:43:11.818>
    user = 'https://bugs.python.org/PeterDavies'

    bugs.python.org fields:

    activity = <Date 2016-09-12.02:43:11.818>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-09-12.02:43:11.820>
    closer = 'berker.peksag'
    components = ['Library (Lib)']
    creation = <Date 2011-03-22.22:15:42.956>
    creator = 'Peter.Davies'
    dependencies = []
    files = ['21345']
    hgrepos = []
    issue_num = 11640
    keywords = ['needs review']
    message_count = 4.0
    messages = ['131793', '141436', '141524', '275925']
    nosy_count = 5.0
    nosy_names = ['stutzbach', 'daniel.urban', 'Peter.Davies', 'petri.lehtinen', 'berker.peksag']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue11640'
    versions = ['Python 2.7', 'Python 3.2', 'Python 3.3', 'Python 3.4']

    @PeterDavies
    Copy link
    Mannequin Author

    PeterDavies mannequin commented Mar 22, 2011

    Shelf.__setitem__ (which is called from __del__ when writeback is enabled) references globals. This was causing exceptions on interpreter shutdown (due to another exception) for me.

    I have attached a patch which stores the relevant globals in the Shelf object.

    @PeterDavies PeterDavies mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Mar 22, 2011
    @akheron
    Copy link
    Member

    akheron commented Jul 30, 2011

    The patch looks good to me. Is there any way this could be tested in the test suite? How to simulate interpreter shutdown?

    @stutzbach
    Copy link
    Mannequin

    stutzbach mannequin commented Aug 1, 2011

    Could you add a comment above the lines defining self._BytesIO, describing why they're being set? Someone else might see them as unnecessary and rip them out if there's no explanation.

    Can a test launch Python in a subprocess, set up the appropriate data structure, let the subprocess Python shutdown, then check the subprocess's stderr for the error?

    It's a little convoluted, but perhaps it could be built into a general utility function that could be used to test __del__ methods in other modules, too.

    Not sure that it's worth the effort though.

    @berkerpeksag
    Copy link
    Member

    Since PEP-442 has been implemented in 3.4 and e826940911c8 made Shelve.close() more robust, I think this is no longer an issue.

    @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