From: Vinay Sajip Date: Wed, 15 Mar 2006 12:45:07 +0000 (+0000) Subject: Catch situations where currentframe() returns None. See SF patch #1447410, this is... X-Git-Tag: v2.5a0~237 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a2173a189a679cd6babf85a0369b1969f173dfb3;p=thirdparty%2FPython%2Fcpython.git Catch situations where currentframe() returns None. See SF patch #1447410, this is a different implementation. --- diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index d82d6671b35b..bc215439b476 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): """