[Python-checkins] r67537 - in python/trunk: Lib/logging/__init__.py Misc/NEWS
vinay.sajip
python-checkins at python.org
Thu Dec 4 21:32:18 CET 2008
Author: vinay.sajip
Date: Thu Dec 4 21:32:18 2008
New Revision: 67537
Log:
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.
Modified:
python/trunk/Lib/logging/__init__.py
python/trunk/Misc/NEWS
Modified: python/trunk/Lib/logging/__init__.py
==============================================================================
--- python/trunk/Lib/logging/__init__.py (original)
+++ python/trunk/Lib/logging/__init__.py Thu Dec 4 21:32:18 2008
@@ -31,7 +31,7 @@
'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 @@
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 @@
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:
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Thu Dec 4 21:32:18 2008
@@ -67,11 +67,11 @@
support unusual filenames (such as those containing semi-colons) in
Content-Disposition headers.
-- Issue #4384: Added integration with warnings module using captureWarnings().
- This change includes a NullHandler which does nothing; it will be of use to
- library developers who want to avoid the "No handlers could be found for
- logger XXX" message which can appear if the library user doesn't configure
- logging.
+- Issue #4384: Added logging integration with warnings module using
+ captureWarnings(). This change includes a NullHandler which does nothing;
+ it will be of use to library developers who want to avoid the "No handlers
+ could be found for logger XXX" message which can appear if the library user
+ doesn't configure logging.
- Issue #3741: DISTUTILS_USE_SDK set causes msvc9compiler.py to raise an
exception.
More information about the Python-checkins
mailing list