diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2006-03-15 12:45:07 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2006-03-15 12:45:07 (GMT) |
commit | a2173a189a679cd6babf85a0369b1969f173dfb3 (patch) | |
tree | 02530c37b4acf1240f3a024fd9efc4b4540d21e9 /Lib/logging/__init__.py | |
parent | 5424ad8a2a24b9a135264df829c65b2f19eec2a4 (diff) | |
download | cpython-a2173a189a679cd6babf85a0369b1969f173dfb3.zip cpython-a2173a189a679cd6babf85a0369b1969f173dfb3.tar.gz cpython-a2173a189a679cd6babf85a0369b1969f173dfb3.tar.bz2 |
Catch situations where currentframe() returns None. See SF patch #1447410, this is a different implementation.
Diffstat (limited to 'Lib/logging/__init__.py')
-rw-r--r-- | Lib/logging/__init__.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index d82d667..bc21543 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): """ |