diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2008-12-04 20:32:18 +0000 |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2008-12-04 20:32:18 +0000 |
commit | 6831d6bc7f4ee97ee854ddaa50f47ec4fb781cd2 (patch) | |
tree | 4d236b05638e3375df311c4a93339b413a248976 /Lib | |
parent | 97f49f4be7ab6d4b570029be4b4439cc29be2f74 (diff) | |
download | cpython-git-6831d6bc7f4ee97ee854ddaa50f47ec4fb781cd2.tar.gz |
Took Nick Coghlan's advice about importing warnings globally in logging, to avoid the possibility of race conditions: "This could deadlock if a thread spawned as a side effect of importing a module happens to trigger a warning. warnings is pulled into sys.modules as part of the interpreter startup - having a global 'import warnings' shouldn't have any real effect on logging's import time."
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/logging/__init__.py | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index c28d7c8650..bd1a49d626 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -31,7 +31,7 @@ __all__ = ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG', 'ERROR', 'INFO', 'LogRecord', 'Logger', 'Manager', 'NOTSET', 'PlaceHolder', 'RootLogger', 'StreamHandler', 'WARN', 'WARNING'] -import sys, os, types, time, string, cStringIO, traceback +import sys, os, types, time, string, cStringIO, traceback, warnings try: import codecs @@ -1520,7 +1520,6 @@ def _showwarning(message, category, filename, lineno, file=None, line=None): if _warnings_showwarning is not None: _warnings_showwarning(message, category, filename, lineno, file, line) else: - import warnings s = warnings.formatwarning(message, category, filename, lineno, line) logger = getLogger("py.warnings") if not logger.handlers: @@ -1533,7 +1532,6 @@ def captureWarnings(capture): If capture is False, ensure that warnings are not redirected to logging but to their original destinations. """ - import warnings global _warnings_showwarning if capture: if _warnings_showwarning is None: |