Morgan243 / python-on-a-chip

Automatically exported from code.google.com/p/python-on-a-chip
Other
0 stars 0 forks source link

Fix yield inside a method #179

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Reported by Oscar on the maillist on 12/26/2010:

I think I stumbled upon yet another little bug.

def free_yielder():
   yield (1, 2, 3)
   yield (10, 20, 30)
def free_printer():
   for v in free_yielder():
       print v

free_printer()

class A:
   def __init__(self):
       pass
   def yielder(self):
       yield (1, 2, 3)
       yield (10, 20, 30)
   def printer(self):
       for v in self.yielder():
           print v

a = A()
a.printer()

Output in cpython:
(1, 2, 3)
(10, 20, 30)
(1, 2, 3)
(10, 20, 30)

Output in pymite:

(1, 2, 3)
(10, 20, 30)
1
2
3

Original issue reported on code.google.com by dwhall...@gmail.com on 28 Dec 2010 at 2:48