Zane Bitter <za...@fedoraproject.org> added the comment:

> 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).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37857>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to