[Python-checkins] r69721 - in python/branches/release26-maint: Lib/logging/__init__.py Misc/NEWS

vinay.sajip python-checkins at python.org
Tue Feb 17 18:47:16 CET 2009


Author: vinay.sajip
Date: Tue Feb 17 18:47:15 2009
New Revision: 69721

Log:
#5287: Add exception handling around findCaller() call to help out IronPython.

Modified:
   python/branches/release26-maint/Lib/logging/__init__.py
   python/branches/release26-maint/Misc/NEWS

Modified: python/branches/release26-maint/Lib/logging/__init__.py
==============================================================================
--- python/branches/release26-maint/Lib/logging/__init__.py	(original)
+++ python/branches/release26-maint/Lib/logging/__init__.py	Tue Feb 17 18:47:15 2009
@@ -1,4 +1,4 @@
-# Copyright 2001-2008 by Vinay Sajip. All Rights Reserved.
+# Copyright 2001-2009 by Vinay Sajip. All Rights Reserved.
 #
 # Permission to use, copy, modify, and distribute this software and its
 # documentation for any purpose and without fee is hereby granted,
@@ -44,7 +44,7 @@
 __author__  = "Vinay Sajip <vinay_sajip at red-dove.com>"
 __status__  = "production"
 __version__ = "0.5.0.5"
-__date__    = "20 January 2009"
+__date__    = "17 February 2009"
 
 #---------------------------------------------------------------------------
 #   Miscellaneous module data
@@ -1118,7 +1118,12 @@
         all the handlers of this logger to handle the record.
         """
         if _srcfile:
-            fn, lno, func = self.findCaller()
+            #IronPython doesn't track Python frames, so findCaller throws an
+            #exception. We trap it here so that IronPython can use logging.
+            try:
+                fn, lno, func = self.findCaller()
+            except ValueError:
+                fn, lno, func = "(unknown file)", 0, "(unknown function)"
         else:
             fn, lno, func = "(unknown file)", 0, "(unknown function)"
         if exc_info:

Modified: python/branches/release26-maint/Misc/NEWS
==============================================================================
--- python/branches/release26-maint/Misc/NEWS	(original)
+++ python/branches/release26-maint/Misc/NEWS	Tue Feb 17 18:47:15 2009
@@ -80,6 +80,9 @@
 Library
 -------
 
+- Issue #5287: Add exception handling around findCaller() call in logging to
+  help out IronPython.
+
 - Issue #4524: distutils build_script command failed with --with-suffix=3.
   Initial patch by Amaury Forgeot d'Arc.
 


More information about the Python-checkins mailing list