homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: mute ImportError in __del__ of _threading_local module
Type: Stage: resolved
Components: Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Zhiping.Deng, ezio.melotti, xtreak
Priority: normal Keywords: patch

Created on 2011年12月28日 13:18 by Zhiping.Deng, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
_threading_local.mute_ImportError.diff Zhiping.Deng, 2011年12月28日 13:18
Messages (3)
msg150288 - (view) Author: Zhiping Deng (Zhiping.Deng) Date: 2011年12月28日 13:18
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')
msg221878 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014年06月29日 18:37
Can this be closed as a result of #9707 and r64543 ?
msg338346 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2019年03月19日 12:00
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.
History
Date User Action Args
2022年04月11日 14:57:25adminsetgithub: 57877
2019年03月19日 12:00:44xtreaksetstatus: open -> closed

nosy: + xtreak
messages: + msg338346

resolution: out of date
stage: resolved
2019年03月16日 00:06:56BreamoreBoysetnosy: - BreamoreBoy
2014年06月29日 18:37:32BreamoreBoysetnosy: + BreamoreBoy
messages: + msg221878
2011年12月29日 00:34:35pitrousetnosy: + ezio.melotti
2011年12月28日 13:18:12Zhiping.Dengcreate

AltStyle によって変換されたページ (->オリジナル) /