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 zaneb
Recipients vinay.sajip, zaneb
Date 2019-09-09.14:11:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> That code in the wild that sets the level attribute directly is wrong and should be changed, right?

It definitely should be changed (and in our case we did change it once we found it). Whether it's "wrong" is more of a philosophical question ;). But the problem with that is that it's very difficult to find - the object's state appears to be set OK but the behaviour doesn't match because of the hidden cache with different values.

> I'm not sure such misuse is widespread.

There's no way to be sure. But if you have a public (i.e. non-underscore-prfixed) attribute then some percentage of people are going to set it, particularly if it seems to work. I went back and looked at how this was introduced in the example I linked, and the patch was reviewed by the guy who literally wrote the book on the Python standard library. That suggests to me that this could happen to anyone. The code doesn't look wrong, so mistakes are going to happen.

> I don't know what the real-world performance impact would be

Me neither, but the good news is that the values are now cached :) So it doesn't impact the performance of logging a message at all. It will have some impact on the performance of rebuilding the cache, but I'd expect it to be negligible in the context of the other work required to rebuild the cache (which includes obtaining a lock).
Date User Action Args
2019-09-09 14:11:30zanebsetrecipients: + zaneb, vinay.sajip
2019-09-09 14:11:30zanebsetmessageid: <>
2019-09-09 14:11:30zaneblinkissue37857 messages
2019-09-09 14:11:30zanebcreate