Oren <[email protected]> added the comment:
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: ()
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue34086>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com