Commit f70867aa authored by Vinay Sajip's avatar Vinay Sajip

Issue #7014: logging: Improved IronPython 2.6 compatibility.

parent dbf3b258
...@@ -282,10 +282,13 @@ class LogRecord: ...@@ -282,10 +282,13 @@ class LogRecord:
else: else:
self.thread = None self.thread = None
self.threadName = None self.threadName = None
if logMultiprocessing: if not logMultiprocessing:
self.processName = None
else:
try:
from multiprocessing import current_process from multiprocessing import current_process
self.processName = current_process().name self.processName = current_process().name
else: except ImportError:
self.processName = None self.processName = None
if logProcesses and hasattr(os, 'getpid'): if logProcesses and hasattr(os, 'getpid'):
self.process = os.getpid() self.process = os.getpid()
...@@ -1125,7 +1128,11 @@ class Logger(Filterer): ...@@ -1125,7 +1128,11 @@ class Logger(Filterer):
Find the stack frame of the caller so that we can note the source Find the stack frame of the caller so that we can note the source
file name, line number and function name. 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)" rv = "(unknown file)", 0, "(unknown function)"
while hasattr(f, "f_code"): while hasattr(f, "f_code"):
co = f.f_code co = f.f_code
...@@ -1157,7 +1164,8 @@ class Logger(Filterer): ...@@ -1157,7 +1164,8 @@ class Logger(Filterer):
""" """
if _srcfile: if _srcfile:
#IronPython doesn't track Python frames, so findCaller throws an #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: try:
fn, lno, func = self.findCaller() fn, lno, func = self.findCaller()
except ValueError: except ValueError:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment