[Python-checkins] python/dist/src/Lib/test test_generators.py,1.33,1.34

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Tue, 11 Jun 2002 20:45:23 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv31088/Lib/test

Modified Files:
	test_generators.py 
Log Message:
SF bug 567538: Generator can crash the interpreter (Finn Bock).

This was a simple typo.  Strange that the compiler didn't catch it!
Instead of WHY_CONTINUE, two tests used CONTINUE_LOOP, which isn't a
why_code at all, but an opcode; but even though 'why' is declared as
an enum, comparing it to an int is apparently not even worth a
warning -- not in gcc, and not in VC++. :-(

Will fix in 2.2 too.


Index: test_generators.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_generators.py,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** test_generators.py	3 Apr 2002 22:41:50 -0000	1.33
--- test_generators.py	12 Jun 2002 03:45:20 -0000	1.34
***************
*** 806,809 ****
--- 806,829 ----
  Traceback (most recent call last):
  SyntaxError: 'return' with argument inside generator (<string>, line 8)
+ 
+ This one caused a crash (see SF bug 567538):
+ 
+ >>> def f():
+ ...     for i in range(3):
+ ...         try:
+ ...             continue
+ ...         finally:
+ ...             yield i
+ ... 
+ >>> g = f()
+ >>> print g.next()
+ 0
+ >>> print g.next()
+ 1
+ >>> print g.next()
+ 2
+ >>> print g.next()
+ Traceback (most recent call last):
+ StopIteration
  """