summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2006-03-20 09:22:40 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2006-03-20 09:22:40 (GMT)
commit2c20676e51c92ab69c4d7cf3d152bc6dd12dab49 (patch)
tree11c5809b62d98fdbe30f0901d3abebb187cd2138
parent099e7932cf5aae6713c20bf3cf3b21465aabe171 (diff)
downloadcpython-2c20676e51c92ab69c4d7cf3d152bc6dd12dab49.zip
cpython-2c20676e51c92ab69c4d7cf3d152bc6dd12dab49.tar.gz
cpython-2c20676e51c92ab69c4d7cf3d152bc6dd12dab49.tar.bz2
Catch situations where currentframe() returns None. See SF patch #1447410, this is a different implementation.
-rw-r--r--Lib/logging/__init__.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 5a0b0f5..a7210e1 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -1045,13 +1045,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):
"""
@@ -1324,12 +1327,14 @@ def shutdown():
"""
for h in _handlerList[:]: # was _handlers.keys():
#errors might occur, for example, if files are locked
- #we just ignore them
+ #we just ignore them if raiseExceptions is not set
try:
h.flush()
h.close()
except:
- pass
+ if raiseExceptions:
+ raise
+ #else, swallow
#Let's try and shutdown automatically on application exit...
try: