1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
# mode: run
# ticket: 1731
def cygen():
yield 1
def test_from_cython(g):
"""
>>> def pygen(): yield 1
>>> test_from_cython(pygen)
Traceback (most recent call last):
ZeroDivisionError: integer division or modulo by zero
>>> test_from_cython(cygen)
Traceback (most recent call last):
ZeroDivisionError: integer division or modulo by zero
"""
try:
1 / 0
except:
for _ in g():
pass
raise
def test_from_python():
"""
>>> def test(g):
... try:
... 1 / 0
... except:
... for _ in g():
... pass
... raise
>>> def pygen():
... yield 1
>>> test(pygen) # doctest: +ELLIPSIS
Traceback (most recent call last):
ZeroDivisionError: ...division ...by zero
>>> test(cygen) # doctest: +ELLIPSIS
Traceback (most recent call last):
ZeroDivisionError: ...division ...by zero
"""
def test_from_console():
"""
>>> def pygen(): yield 1
>>> try: # doctest: +ELLIPSIS
... 1 / 0
... except:
... for _ in pygen():
... pass
... raise
Traceback (most recent call last):
ZeroDivisionError: ...division ...by zero
>>> try: # doctest: +ELLIPSIS
... 1 / 0
... except:
... for _ in cygen():
... pass
... raise
Traceback (most recent call last):
ZeroDivisionError: ...division ...by zero
"""
|