]> granicus.if.org Git - python/commitdiff
Issue #7014: logging: Improved IronPython 2.6 compatibility.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Tue, 29 Sep 2009 07:11:53 +0000 (07:11 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Tue, 29 Sep 2009 07:11:53 +0000 (07:11 +0000)
Lib/logging/__init__.py

index c1678b79e2dfd2cfb65c171ffc622b14277e2a5f..2b8a02172405d65a233c1f1e08af144dbf16fe4d 100644 (file)
@@ -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:
@@ -1114,7 +1117,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