summaryrefslogtreecommitdiffstats
path: root/Lib/logging/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/logging/__init__.py')
-rw-r--r--Lib/logging/__init__.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index f932110..fecca2b 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -271,11 +271,14 @@ class LogRecord:
else:
self.thread = None
self.threadName = None
- if logMultiprocessing:
- from multiprocessing import current_process
- self.processName = current_process().name
- else:
+ if not logMultiprocessing:
self.processName = None
+ else:
+ try:
+ from multiprocessing import current_process
+ self.processName = current_process().name
+ except ImportError:
+ self.processName = None
if logProcesses and hasattr(os, 'getpid'):
self.process = os.getpid()
else:
@@ -734,16 +737,16 @@ class StreamHandler(Handler):
sys.stdout or sys.stderr may be used.
"""
- def __init__(self, strm=None):
+ def __init__(self, stream=None):
"""
Initialize the handler.
- If strm is not specified, sys.stderr is used.
+ If stream is not specified, sys.stderr is used.
"""
Handler.__init__(self)
- if strm is None:
- strm = sys.stderr
- self.stream = strm
+ if stream is None:
+ stream = sys.stderr
+ self.stream = stream
def flush(self):
"""
@@ -1113,7 +1116,11 @@ class Logger(Filterer):
Find the stack frame of the caller so that we can note the source
file name, line number and function name.
"""
- f = currentframe().f_back
+ f = currentframe()
+ #On some versions of IronPython, currentframe() returns None if
+ #IronPython isn't run with -X:Frames.
+ if f is not None:
+ f = f.f_back
rv = "(unknown file)", 0, "(unknown function)"
while hasattr(f, "f_code"):
co = f.f_code
@@ -1145,7 +1152,8 @@ class Logger(Filterer):
"""
if _srcfile:
#IronPython doesn't track Python frames, so findCaller throws an
- #exception. We trap it here so that IronPython can use logging.
+ #exception on some versions of IronPython. We trap it here so that
+ #IronPython can use logging.
try:
fn, lno, func = self.findCaller()
except ValueError: