Message321392
I realize that there is a legitimate argument that handleError() is being used wrong in the example, but since it used to work, it'd be nice if it still did. I came across this after converting a codebase to python3 and it took a while for this problem to appear.
I propose the following fix:
$ git diff
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 29a7d46..f2c3023 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -908,7 +908,7 @@ class Handler(Filterer):
sys.stderr.write('Call stack:\n')
# Walk the stack frame up until we're out of logging,
# so as to print the calling context.
- frame = tb.tb_frame
+ frame = tb and tb.tb_frame
while (frame and os.path.dirname(frame.f_code.co_filename) ==
__path__[0]):
frame = frame.f_back
This results in:
$ python3 logbug.py
--- Logging error ---
NoneType: None
Call stack:
Logged from file logbug.py, line 15
Message: 'this will work in python 2.7, but not 3'
Arguments: () |
|
Date |
User |
Action |
Args |
2018-07-10 18:01:10 | oren | set | recipients:
+ oren |
2018-07-10 18:01:10 | oren | set | messageid: <1531245670.02.0.56676864532.issue34086@psf.upfronthosting.co.za> |
2018-07-10 18:01:10 | oren | link | issue34086 messages |
2018-07-10 18:01:09 | oren | create | |
|