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

mute ImportError in __del__ of _threading_local module #57877

Closed
ZhipingDeng mannequin opened this issue Dec 28, 2011 · 3 comments
Closed

mute ImportError in __del__ of _threading_local module #57877

ZhipingDeng mannequin opened this issue Dec 28, 2011 · 3 comments

Comments

@ZhipingDeng
Copy link
Mannequin

ZhipingDeng mannequin commented Dec 28, 2011

BPO 13668
Nosy @ezio-melotti, @tirkarthi
Files
  • _threading_local.mute_ImportError.diff
  • 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 2019-03-19.12:00:44.818>
    created_at = <Date 2011-12-28.13:18:12.401>
    labels = []
    title = 'mute ImportError in __del__ of _threading_local module'
    updated_at = <Date 2019-03-19.12:00:44.817>
    user = 'https://bugs.python.org/ZhipingDeng'

    bugs.python.org fields:

    activity = <Date 2019-03-19.12:00:44.817>
    actor = 'xtreak'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-03-19.12:00:44.818>
    closer = 'xtreak'
    components = []
    creation = <Date 2011-12-28.13:18:12.401>
    creator = 'Zhiping.Deng'
    dependencies = []
    files = ['24097']
    hgrepos = []
    issue_num = 13668
    keywords = ['patch']
    message_count = 3.0
    messages = ['150288', '221878', '338346']
    nosy_count = 3.0
    nosy_names = ['ezio.melotti', 'Zhiping.Deng', 'xtreak']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue13668'
    versions = ['Python 2.7']

    @ZhipingDeng
    Copy link
    Mannequin Author

    ZhipingDeng mannequin commented Dec 28, 2011

    If python was configured without-threads:

    % ./python
    Python 2.7.2+ (2.7:e71e4bd45c89, Dec 28 2011, 21:03:59) 
    [GCC 4.4.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import dummy_threading as _threading
    >>> a = _threading.local()
    >>> del a
    Exception ImportError: ImportError('No module named thread',) in <bound method local.__del__ of <_threading_local.local object at 0xb7681694>> ignored
    Patch to mute this Exception:
    diff --git a/Lib/_threading_local.py b/Lib/_threading_local.py
    --- a/Lib/_threading_local.py
    +++ b/Lib/_threading_local.py
    @@ -221,7 +221,13 @@
                 lock.release()
     
         def __del__(self):
    -        import threading
    +        try:
    +            import threading
    +        except ImportError:
    +            import sys
    +            if '_dummy_threading' in sys.modules:
    +                return
    +            raise
     
             key = object.__getattribute__(self, '_local__key')

    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jun 29, 2014

    Can this be closed as a result of bpo-9707 and r64543 ?

    @tirkarthi
    Copy link
    Member

    As noted in msg221878 the import statement was removed and the original report is not reproducible in latest 2.7. Marking this as out of date. Thanks for the details.

    @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
    None yet
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant