4 ms·
If # of lines are important, this problem can actually be demonstrated in 1 line: for x, x.__new__ in [(__import__('queue').Full, print)]: __import__('glo
by paulddraper 7y ago
If # of lines are important, this problem can actually be demonstrated in 1 line:
for x, x.__new__ in [(__import__('queue').Full, print)]: __import__('glob').iglob(0).throw(x)
- filmor 7y agoThis 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}))