]> granicus.if.org Git - python/commitdiff
Catch situations where currentframe() returns None. See SF patch #1447410, this is...
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Wed, 15 Mar 2006 12:45:07 +0000 (12:45 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Wed, 15 Mar 2006 12:45:07 +0000 (12:45 +0000)
Lib/logging/__init__.py

index d82d6671b35ba9999c0877baac85bbc7ac4d1173..bc215439b4761b02f4f2cc8172c21d436d7ca25a 100644 (file)
@@ -1058,13 +1058,16 @@ class Logger(Filterer):
         file name, line number and function name.
         """
         f = currentframe().f_back
-        while 1:
+        rv = "(unknown file)", 0, "(unknown function)"
+        while hasattr(f, "f_code"):
             co = f.f_code
             filename = os.path.normcase(co.co_filename)
             if filename == _srcfile:
                 f = f.f_back
                 continue
-            return filename, f.f_lineno, co.co_name
+            rv = (filename, f.f_lineno, co.co_name)
+            break
+        return rv
 
     def makeRecord(self, name, level, fn, lno, msg, args, exc_info, func=None, extra=None):
         """