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 mp5023
Recipients krivushinme, mp5023, rhettinger, serhiy.storchaka, vinay.sajip
Date 2017-10-12.16:17:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1507825027.28.0.213398074469.issue30767@psf.upfronthosting.co.za>
In-reply-to
Content
I believe this diff addresses the failure of formatException() to check it's parameter's datatype. I still maintain this should be re-opened since it's guaranteed to raise an exception when someone sets 'exc_info=TruthyValue' in kwargs. albeit with a more focused PR.


diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 00a022039d..5c61cd56a1 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -533,6 +533,8 @@ class Formatter(object):
         This default implementation just uses
         traceback.print_exception()
         """
+        if not isinstance(ei, tuple) or ei[0] is None:
+            return ""
         sio = io.StringIO()
         tb = ei[2]
         # See issues #9427, #1553375. Commented out for now.
@@ -584,9 +586,7 @@ class Formatter(object):
         if self.usesTime():
             record.asctime = self.formatTime(record, self.datefmt)
         s = self.formatMessage(record)
-        if (isinstance(record.exc_info, tuple) and record.exc_info[0]):
-            # Intercept 'Boolean' - causes subscript error if passed to formatException,
-            # and empty Tuples which emit 'NoneType None' into message.
+        if record.exc_info:
             # Cache the traceback text to avoid converting it multiple times
             # (it's constant anyway)
             if not record.exc_text:
History
Date User Action Args
2017-10-12 16:17:07mp5023setrecipients: + mp5023, rhettinger, vinay.sajip, serhiy.storchaka, krivushinme
2017-10-12 16:17:07mp5023setmessageid: <1507825027.28.0.213398074469.issue30767@psf.upfronthosting.co.za>
2017-10-12 16:17:07mp5023linkissue30767 messages
2017-10-12 16:17:07mp5023create