fork(2) download
  1. import dis, traceback, sys
  2. def foo(it):
  3. return iter(it)
  4. def bar(it):
  5. return (yield from it)
  6. def test(f):
  7. dis.dis(f)
  8. def i():
  9. yield 1
  10. raise RuntimeError
  11. try:
  12. for x in f(i()):
  13. pass
  14. except:
  15. traceback.print_exc(file=sys.stdout)
  16. test(foo)
  17. test(bar)
Success #stdin #stdout 0.04s 9096KB
stdin
Standard input is empty
stdout
  3           0 LOAD_GLOBAL              0 (iter)
              3 LOAD_FAST                0 (it)
              6 CALL_FUNCTION            1 (1 positional, 0 keyword pair)
              9 RETURN_VALUE
Traceback (most recent call last):
  File "./prog.py", line 12, in test
  File "./prog.py", line 10, in i
RuntimeError
  5           0 LOAD_FAST                0 (it)
              3 GET_ITER
              4 LOAD_CONST               0 (None)
              7 YIELD_FROM
              8 RETURN_VALUE
Traceback (most recent call last):
  File "./prog.py", line 12, in test
  File "./prog.py", line 5, in bar
  File "./prog.py", line 10, in i
RuntimeError