[Python-checkins] CVS: python/dist/src/Lib/test test_generators.py,1.12,1.13

Tim Peters tim_one@users.sourceforge.net
Wed, 27 Jun 2001 18:52:24 -0700


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

Modified Files:
	test_generators.py 
Log Message:
Another "if 0:" hack, this time to complain about otherwise invisible
"return expr" instances in generators (which latter may be generators
due to otherwise invisible "yield" stmts hiding in "if 0" blocks).
This was fun the first time, but this has gotten truly ugly now.


Index: test_generators.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_generators.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** test_generators.py	2001/06/27 07:17:57	1.12
--- test_generators.py	2001/06/28 01:52:22	1.13
***************
*** 653,656 ****
--- 653,667 ----
  
  >>> def f():
+ ...    yield
+ Traceback (most recent call last):
+ SyntaxError: invalid syntax
+ 
+ >>> def f():
+ ...    if 0:
+ ...        yield
+ Traceback (most recent call last):
+ SyntaxError: invalid syntax
+ 
+ >>> def f():
  ...     if 0:
  ...         yield 1
***************
*** 705,708 ****
--- 716,741 ----
  >>> type(f())
  <type 'None'>
+ 
+ >>> def f():
+ ...     if 0:
+ ...         return
+ ...     if 0:
+ ...         yield 2
+ >>> type(f())
+ <type 'generator'>
+ 
+ 
+ >>> def f():
+ ...     if 0:
+ ...         lambda x:  x        # shouldn't trigger here
+ ...         return              # or here
+ ...         def f(i):
+ ...             return 2*i      # or here
+ ...         if 0:
+ ...             return 3        # but *this* sucks (line 8)
+ ...     if 0:
+ ...         yield 2             # because it's a generator
+ Traceback (most recent call last):
+ SyntaxError: 'return' with argument inside generator (<string>, line 8)
  """