]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#5287: Add exception handling around findCaller() call to help out IronPython.
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Tue, 17 Feb 2009 17:47:15 +0000 (17:47 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Tue, 17 Feb 2009 17:47:15 +0000 (17:47 +0000)
Lib/logging/__init__.py
Misc/NEWS

index dd44b67aac7a6415febca3329843b6a20f48d5ed..90fe5816719d28a6dfe76a9debb2784a90ca167c 100644 (file)
@@ -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 @@ except ImportError:
 __author__  = "Vinay Sajip <vinay_sajip@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 @@ class Logger(Filterer):
         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:
index 9b734d0973d09ad50b9e6da1dc1896651b42f626..45d145e9209c4c4427963fccf581d5045fab5c01 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -80,6 +80,9 @@ Core and Builtins
 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.