This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author oren
Recipients oren
Date 2018-07-10.18:01:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1531245670.02.0.56676864532.issue34086@psf.upfronthosting.co.za>
In-reply-to
Content
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: ()
History
Date User Action Args
2018-07-10 18:01:10orensetrecipients: + oren
2018-07-10 18:01:10orensetmessageid: <1531245670.02.0.56676864532.issue34086@psf.upfronthosting.co.za>
2018-07-10 18:01:10orenlinkissue34086 messages
2018-07-10 18:01:09orencreate