[Python-checkins] python/dist/src/Lib/test test_generators.py,1.30,1.30.6.1

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


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

Modified Files:
      Tag: release22-maint
	test_generators.py 
Log Message:
Backport:

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++. :-(


Index: test_generators.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_generators.py,v
retrieving revision 1.30
retrieving revision 1.30.6.1
diff -C2 -d -r1.30 -r1.30.6.1
*** test_generators.py	6 Dec 2001 06:23:25 -0000	1.30
--- test_generators.py	12 Jun 2002 03:48:46 -0000	1.30.6.1
***************
*** 808,811 ****
--- 808,831 ----
  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
  """