4 ms·
This doesn't trigger a segfault for me in Python 3.7, just an exception that `print_exception` expects an `Exception`. Someone commented below the gist with th
by filmor 7y ago
This doesn't trigger a segfault for me in Python 3.7, just an exception that `print_exception` expects an `Exception`.
Someone commented below the gist with this one-liner:
(i for i in []).throw(type('E', (BaseException,), dict(__new__=lambda cls, *args: cls))())
I managed to golf it a bit down to this ;):
n="__new__";(i for i in []).throw(type(n,(IOError,),{n:lambda c,*a:c})())
- ehsankia 7y agoJust one character but replace `[]` with `n` too :)
- chrismorgan 7y agoOr save that character by removing the space before `[]` instead (which you can’t do if you write `n`).
- paulddraper 7y agoMine produces segfault with $ python3.7 -VV Python 3.7.5 (default, Nov 7 2019, 10:50:52) [GCC 8.3.0] Some more golfing with yours: (i for i in[]).throw(type('',(IOError,),{'__new__':lambda a,*b:a}))