mirror of
https://github.com/python/cpython.git
synced 2025-11-11 14:44:57 +00:00
Catch situations where currentframe() returns None. See SF patch #1447410, this is a different implementation.
This commit is contained in:
parent
5424ad8a2a
commit
a2173a189a
1 changed files with 5 additions and 2 deletions
|
|
@ -1058,13 +1058,16 @@ class Logger(Filterer):
|
||||||
file name, line number and function name.
|
file name, line number and function name.
|
||||||
"""
|
"""
|
||||||
f = currentframe().f_back
|
f = currentframe().f_back
|
||||||
while 1:
|
rv = "(unknown file)", 0, "(unknown function)"
|
||||||
|
while hasattr(f, "f_code"):
|
||||||
co = f.f_code
|
co = f.f_code
|
||||||
filename = os.path.normcase(co.co_filename)
|
filename = os.path.normcase(co.co_filename)
|
||||||
if filename == _srcfile:
|
if filename == _srcfile:
|
||||||
f = f.f_back
|
f = f.f_back
|
||||||
continue
|
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):
|
def makeRecord(self, name, level, fn, lno, msg, args, exc_info, func=None, extra=None):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue