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 alan.briolat
Recipients alan.briolat
Date 2014-04-07.17:04:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1396890277.61.0.522199976389.issue21172@psf.upfronthosting.co.za>
In-reply-to
Content
The logging.LogRecord class is more restrictive with its "first arg is dict" case than the formatting operator it uses requires.  As far as I can tell, for "%(foo)s" % bar, the minimum contract is that bar.__getitem__("foo") succeeds, not that bar is an instance of dict.  However, fulfilling only this minimum contract results in LogRecord raising an exception at the point of applying the string format, which is confusing considering the "same" expression succeeds outside of logging.  See the attached file for how 2 "equivalent" expressions behave completely differently.

For resolution, I wonder if checking for "hasattr(..., '__getitem__')" instead of "isinstance(..., dict)" would be sufficient?
History
Date User Action Args
2014-04-07 17:04:37alan.briolatsetrecipients: + alan.briolat
2014-04-07 17:04:37alan.briolatsetmessageid: <1396890277.61.0.522199976389.issue21172@psf.upfronthosting.co.za>
2014-04-07 17:04:37alan.briolatlinkissue21172 messages
2014-04-07 17:04:37alan.briolatcreate