mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
dynamo: Don't crash when someone tries to access a non existent list member (#156335)
dynamo: Don't crash when someone tries to access a non existent list member Test added which reproduces the failure. Note that I'm using the new unimplemented_v2 API. Let me know if people have a strong preference that I use something else. Pull Request resolved: https://github.com/pytorch/pytorch/pull/156335 Approved by: https://github.com/jansel
This commit is contained in:
@ -116,7 +116,12 @@ class BaseListVariable(VariableTracker):
|
||||
)
|
||||
else:
|
||||
assert isinstance(index, (int, torch.SymInt))
|
||||
return self.items[index]
|
||||
try:
|
||||
return self.items[index]
|
||||
except IndexError:
|
||||
raise_observed_exception(
|
||||
IndexError, tx, args=["list index out of range"]
|
||||
)
|
||||
|
||||
def unpack_var_sequence(self, tx):
|
||||
return list(self.items)
|
||||
|
Reference in New Issue
Block a user