Commit 6940f10b authored by Kevin Modzelewski's avatar Kevin Modzelewski

Add a test for a case we put the decref too early

Not sure if it matters, but there are some cases that our
refcounter will add decrefs earlier than CPython would, if it
can prove that the variable won't end up getting used.

One example is in:

for i in foo():
  break

The iterator object (`iter(foo())`) will not get used after the first
call to next().  So our system will put the decref at the top of the loop.
CPython will do the decref after the loop exits, like normal.
parent 520c1192
# fail-if: '-n' in EXTRA_JIT_ARGS or '-O' in EXTRA_JIT_ARGS
class C(object):
def next(self):
return 1
def __del__(self):
print "del"
class D(object):
def __iter__(self):
return C()
def f():
for i in D():
print i
break
for i in xrange(100):
print
f()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment