From 40559bb1b07035ed9cda76ad85449a68e42588bc Mon Sep 17 00:00:00 2001 From: "vinay.sajip" Date: Wed, 15 Mar 2006 12:45:07 +0000 Subject: [PATCH] Catch situations where currentframe() returns None. See SF patch #1447410, this is a different implementation. git-svn-id: http://svn.python.org/projects/python/trunk@43048 6015fed2-1504-0410-9fe1-9d1591cc4771 --- Lib/logging/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index d82d6671b3..bc215439b4 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -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): """ -- 2.11.4.GIT