Skip to content

Commit

Permalink
Fix error propagation from list init
Browse files Browse the repository at this point in the history
  • Loading branch information
t-vi committed Mar 23, 2024
1 parent b8074a0 commit 5c96d18
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 3 additions & 2 deletions thunder/core/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2101,8 +2101,9 @@ def __new__(cls, iterable=()):
return wrap_const(cls.value())

def __init__(self, iterable=()):
SequenceWrapperMethods.__init__(self, iterable)
return wrap_const(None)
# We need to propagate the return value because it could be JIT_SIGNALS
res = SequenceWrapperMethods.__init__(self, iterable)
return res

def __setitem__(self, key, value, /):
self.track_items()
Expand Down
15 changes: 15 additions & 0 deletions thunder/tests/test_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3001,6 +3001,21 @@ def foo():
assert foo() == jit(foo)()


def test_exception_in_list_init(jit):
def foo(l):
for i in l:
yield i

def bar():
return list(foo(2))

with pytest.raises(TypeError):
bar()

with pytest.raises(TypeError):
jit(bar)()


#
# Network tests
#
Expand Down

0 comments on commit 5c96d18

Please sign in to comment.