[Python-checkins] r43171 - python/branches/release24-maint/Lib/logging/__init__.py
vinay.sajip
python-checkins at python.org
Mon Mar 20 10:22:40 CET 2006
Author: vinay.sajip
Date: Mon Mar 20 10:22:40 2006
New Revision: 43171
Modified:
python/branches/release24-maint/Lib/logging/__init__.py
Log:
Catch situations where currentframe() returns None. See SF patch #1447410, this is a different implementation.
Modified: python/branches/release24-maint/Lib/logging/__init__.py
==============================================================================
--- python/branches/release24-maint/Lib/logging/__init__.py (original)
+++ python/branches/release24-maint/Lib/logging/__init__.py Mon Mar 20 10:22:40 2006
@@ -1045,13 +1045,16 @@
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 @@
"""
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:
More information about the Python-checkins
mailing list