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 <>
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?
Date User Action Args
2014-04-07 17:04:37alan.briolatsetrecipients: + alan.briolat
2014-04-07 17:04:37alan.briolatsetmessageid: <>
2014-04-07 17:04:37alan.briolatlinkissue21172 messages
2014-04-07 17:04:37alan.briolatcreate