Message215713
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:37 | alan.briolat | set | recipients:
+ alan.briolat |
2014-04-07 17:04:37 | alan.briolat | set | messageid: <1396890277.61.0.522199976389.issue21172@psf.upfronthosting.co.za> |
2014-04-07 17:04:37 | alan.briolat | link | issue21172 messages |
2014-04-07 17:04:37 | alan.briolat | create | |
|