Commit a3f0d747 authored by Michael Arntzenius's avatar Michael Arntzenius

add _make to our NamedTuple stub, add test for bug found implementing it

parent cd9f3a0f
......@@ -422,6 +422,13 @@ def namedtuple(name, fields):
for i in xrange(len(fields)):
setattr(self, fields[i], args[i])
@classmethod
def _make(cls, iterable):
t = tuple(iterable)
if len(t) != len(fields):
raise TypeError('Expected %d arguments, got %d' % (len(fields), len(t)))
return cls(*t)
def __getitem__(self, idx):
assert 0 <= idx < len(fields)
return getattr(self, fields[idx])
......
......@@ -1832,6 +1832,7 @@ private:
endBlock(DEAD);
// This is tripping in test/tests/return_selfreferential.py
ASSERT(rtn->getVrefs() == 1, "%d", rtn->getVrefs());
assert(rtn->getValue());
emitter.getBuilder()->CreateRet(rtn->getValue());
......
# fail-if: ('-n' in EXTRA_JIT_ARGS) or ('-O' in EXTRA_JIT_ARGS)
# trips an assert about vref counts in irgenerator.cpp: IrGeneratorImpl::doReturn()
def f1():
def bar(x):
print 'bar(%s)' % x
if x:
return bar(0)
return x
return bar
g = f1()
print g(2)
def makeA():
class A(object):
def __init__(self, *args):
self.args = args
@classmethod
def _make(cls, *args):
tmp = A
return cls(*args)
return A
def f2():
A = makeA()
return A(1,2,3)
a = f2()
print a.args
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