[Python-checkins] CVS: python/dist/src/Lib/test test_generators.py,1.10,1.11
Tim Peters
tim_one@users.sourceforge.net
Tue, 26 Jun 2001 15:24:53 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv32237/python/dist/src/Lib/test
Modified Files:
test_generators.py
Log Message:
gen_getattr: make the gi_running and gi_frame members discoverable (but
not writable -- too dangerous!) from Python code.
Index: test_generators.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_generators.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** test_generators.py 2001/06/26 03:36:28 1.10
--- test_generators.py 2001/06/26 22:24:51 1.11
***************
*** 369,373 ****
5-combs of [1, 2, 3, 4]:
! # From the Iterators list, about the types of these things.
>>> def g():
--- 369,373 ----
5-combs of [1, 2, 3, 4]:
! From the Iterators list, about the types of these things.
>>> def g():
***************
*** 380,384 ****
<type 'generator'>
>>> dir(i)
! ['next']
>>> print i.next.__doc__
next() -- get the next value, or raise StopIteration
--- 380,384 ----
<type 'generator'>
>>> dir(i)
! ['gi_frame', 'gi_running', 'next']
>>> print i.next.__doc__
next() -- get the next value, or raise StopIteration
***************
*** 388,391 ****
--- 388,411 ----
>>> isinstance(i, types.GeneratorType)
1
+
+ And more, added later.
+
+ >>> i.gi_running
+ 0
+ >>> type(i.gi_frame)
+ <type 'frame'>
+ >>> i.gi_running = 42
+ Traceback (most recent call last):
+ ...
+ TypeError: object has read-only attributes
+ >>> def g():
+ ... yield me.gi_running
+ >>> me = g()
+ >>> me.gi_running
+ 0
+ >>> me.next()
+ 1
+ >>> me.gi_running
+ 0
"""