On Mon, Mar 6, 2017 at 5:52 PM, Tim Peters <tim.pet...@gmail.com> wrote: > [Chris Angelico <ros...@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.
Exactly. It's always fun to discover some nice tidy exception that cleanly copes with a ridiculous situation. def gen(): yield next(g) g = gen() next(g) Fortunately in this case, the solution isn't to say "SystemError: cannot create threads while sorting", but even if that were the case, I can't imagine that much production code would be stopped by it. ChrisA _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/