Re: [Cython] Recent bugs in generators

2011-04-20 Thread Vitja Makarov
2011/4/20 Stefan Behnel : > Vitja Makarov, 20.04.2011 12:51: >> >> 2011/4/20 Stefan Behnel: >>> >>> Vitja Makarov, 20.04.2011 11:50: 2011/4/20 Stefan Behnel: > > Vitja Makarov, 20.04.2011 10:26: >> >> 2011/4/18 Stefan Behnel: >>> >>> generators have their own lifet

Re: [Cython] Recent bugs in generators

2011-04-20 Thread Stefan Behnel
Vitja Makarov, 20.04.2011 12:51: 2011/4/20 Stefan Behnel: Vitja Makarov, 20.04.2011 11:50: 2011/4/20 Stefan Behnel: Vitja Makarov, 20.04.2011 10:26: 2011/4/18 Stefan Behnel: generators have their own lifetime frame in CPython, and exceptions don't leak from that. So, whenever it's the ge

Re: [Cython] Recent bugs in generators

2011-04-20 Thread Vitja Makarov
2011/4/20 Stefan Behnel : > Vitja Makarov, 20.04.2011 11:50: >> >> 2011/4/20 Stefan Behnel: >>> >>> Vitja Makarov, 20.04.2011 10:26: 2011/4/18 Stefan Behnel: > > generators have their own lifetime frame in CPython, and > exceptions don't leak from that. So, whenever it's the g

Re: [Cython] Recent bugs in generators

2011-04-20 Thread Stefan Behnel
Vitja Makarov, 20.04.2011 11:50: 2011/4/20 Stefan Behnel: Vitja Makarov, 20.04.2011 10:26: 2011/4/18 Stefan Behnel: generators have their own lifetime frame in CPython, and exceptions don't leak from that. So, whenever it's the generator (or code called by it) that raises an exception, that mu

Re: [Cython] Recent bugs in generators

2011-04-20 Thread Vitja Makarov
2011/4/20 Stefan Behnel : > Vitja Makarov, 20.04.2011 10:26: >> >> 2011/4/18 Stefan Behnel: >>> >>> Vitja Makarov, 18.04.2011 06:38: 2011/4/18 Stefan Behnel: > > Vitja Makarov, 17.04.2011 17:57: >> >> 3. check_yield_in_exception() > > I added this because I found a

Re: [Cython] Recent bugs in generators

2011-04-20 Thread Stefan Behnel
Vitja Makarov, 20.04.2011 10:26: 2011/4/18 Stefan Behnel: Vitja Makarov, 18.04.2011 06:38: 2011/4/18 Stefan Behnel: Vitja Makarov, 17.04.2011 17:57: 3. check_yield_in_exception() I added this because I found a failing pyregr test that uses it (testing the @contextmanager decorator). C

Re: [Cython] Recent bugs in generators

2011-04-20 Thread Vitja Makarov
2011/4/18 Stefan Behnel : > Vitja Makarov, 18.04.2011 06:38: >> >> 2011/4/18 Stefan Behnel: >>> >>> Vitja Makarov, 17.04.2011 17:57: 3. check_yield_in_exception() >>> >>> I added this because I found a failing pyregr test that uses it (testing >>> the >>> @contextmanager decorator). >>> >

Re: [Cython] Recent bugs in generators

2011-04-18 Thread Vitja Makarov
2011/4/19 Stefan Behnel : > Vitja Makarov, 18.04.2011 15:19: >> >> There is one more interesting thing: >> >> def test_yield_inside_genexp(): >>     """ >>     >>>  o = test_yield_inside_genexp() >>     >>>  list(o) >>     [0, None, 1, None, 2, None] >>     """ >>     return ((yield i) for i in ran

Re: [Cython] Recent bugs in generators

2011-04-18 Thread Stefan Behnel
Vitja Makarov, 18.04.2011 15:19: There is one more interesting thing: def test_yield_inside_genexp(): """ >>> o = test_yield_inside_genexp() >>> list(o) [0, None, 1, None, 2, None] """ return ((yield i) for i in range(3)) Impressively ugly. I guess we should st

Re: [Cython] Recent bugs in generators

2011-04-18 Thread Vitja Makarov
2011/4/18 Stefan Behnel : > Vitja Makarov, 18.04.2011 06:38: >> >> 2011/4/18 Stefan Behnel: >>> >>> Vitja Makarov, 17.04.2011 17:57: 3. check_yield_in_exception() >>> >>> I added this because I found a failing pyregr test that uses it (testing >>> the >>> @contextmanager decorator). >>> >

Re: [Cython] Recent bugs in generators

2011-04-17 Thread Stefan Behnel
Vitja Makarov, 18.04.2011 06:38: 2011/4/18 Stefan Behnel: Vitja Makarov, 17.04.2011 17:57: 3. check_yield_in_exception() I added this because I found a failing pyregr test that uses it (testing the @contextmanager decorator). Cython calls __Pyx_ExceptionReset when except block is done, so

Re: [Cython] Recent bugs in generators

2011-04-17 Thread Vitja Makarov
2011/4/18 Stefan Behnel : > Vitja Makarov, 17.04.2011 17:57: >> >> 3. check_yield_in_exception() > > I added this because I found a failing pyregr test that uses it (testing the > @contextmanager decorator). > > >> Cython calls __Pyx_ExceptionReset when except block is done, so when >> yield is the

Re: [Cython] Recent bugs in generators

2011-04-17 Thread Stefan Behnel
Vitja Makarov, 17.04.2011 17:57: 3. check_yield_in_exception() I added this because I found a failing pyregr test that uses it (testing the @contextmanager decorator). Cython calls __Pyx_ExceptionReset when except block is done, so when yield is there no exception reset is called. I'm not

[Cython] Recent bugs in generators

2011-04-17 Thread Vitja Makarov
Hi! 1. Lambda-generator: Previous implementation was inspired by Python2.6: >>> list((lambda:((yield 1), (yield 2)))()) [1, 2, (None, None)] things changed in python2.7: >>> list((lambda:((yield 1), (yield 2)))()) [1, 2] 2. GeneratorExit is initialized to StopIteration when running generators_p