Message310793
It doesn't even care if the result it gets from ob.__getattribute__("__class__") isn't a type.
Surely `isinstance` is intended to do what it is named and be guaranteed to return True if an object `ob` is an instance of class `cls`. There are already ways to trick `isinstance` into thinking objects are instances of types not present in its __mro__, ie with abstract base classes. All this does is introduce the possibility of bugs.
`inspect.isclass` in particular is affected. If there's some obscure use case for breaking `isinstance` in this manner, surely it shouldn't apply to `inspect.isclass` which according to its documentation, "Return true if the object is a class."
from inspect import isclass
class Liar:
def __getattribute__(self, attr):
if attr == '__class__':
return type
return object.__getattribute__(self, attr)
>>> islcass(Liar())
True |
|
Date |
User |
Action |
Args |
2018-01-26 21:10:40 | bup | set | recipients:
+ bup |
2018-01-26 21:10:40 | bup | set | messageid: <1517001040.56.0.467229070634.issue32683@psf.upfronthosting.co.za> |
2018-01-26 21:10:40 | bup | link | issue32683 messages |
2018-01-26 21:10:40 | bup | create | |
|