[Python-ideas] Exploiting type-homogeneity in list.sort() (again!)
Tim Peters
tim.peters at gmail.com
Mon Mar 6 01:52:33 EST 2017
[Chris Angelico <rosuav at gmail.com>]
> Arbitrary comparison functions let you do anything.... but whoa, I
> cannot imagine any way that this would ever happen outside of "hey
> look, here's how you can trigger a SystemError"!
CPython is full of defensive code protecting against malicious crap.
That's why it rarely crashes ;-)
def __lt__(self, other):
return self.size < other.size
Looks harmless? Can't tell! For all we know, there are proxy
objects, and other.__getattr__ invokes some elaborate library to open
a socket in a new thread to fetch the value of `size` over a network.
More information about the Python-ideas
mailing list