Open ms-jpq opened 4 years ago
It could also implement __bool__
itself (returning True
always), couldn't it? https://docs.python.org/3.8/reference/datamodel.html?highlight=__del__#object.__bool__
I think thats an excellent idea, even though it would be a breaking change.
im not sure what our policy is on that though
Are there any circumstances that you would the buffer to be false-y
?
I think it seems reasonable to override __bool__
. It seems unlikely to break anything? Unless it returns false
when there are no lines and people are relying on that.
ya, thats the case.
a very minor breaking change, but then again i wouldn't be surprised if people actually relied on it.
PR welcome. We monkey-patch various things, this is more or less idiomatic in python land.
The Buffer class makes unexpected RPC calls.
This is due to the
__len__
method being called during boolean tests.For example, the following code will print
2
.This is very surprising behaviour, and there is absoutely no way to fix it without breaking backwards compatibility.
But it should be documentated, because this will actually break your code if you are using
Buffer
class from another thread.It took me a quite a bit of effort to figure out that an
or
statement was causing crashes in my plugin.