mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Improve error message when accessing attributes that don't exist (#1936)
New: >>> torch.autograd.Variable(torch.randn(3, 3)).foobar AttributeError: 'Variable' object has no attribute 'foobar' Old: >>> torch.autograd.Variable(torch.randn(3, 3)).foobar AttributeError: foobar
This commit is contained in:
parent
8a4eb50ed1
commit
0a95613cef
|
|
@ -61,7 +61,7 @@ class Variable(_C._VariableBase):
|
|||
def __getattr__(self, name):
|
||||
if name in self._fallthrough_methods:
|
||||
return getattr(self.data, name)
|
||||
raise AttributeError(name)
|
||||
return object.__getattribute__(self, name)
|
||||
|
||||
def __getitem__(self, key):
|
||||
if torch.is_tensor(key):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user