{"action":"opened","issue":{"url":"https://api.github.com/repos/pfnet/chainer/issues/2787","repository_url":"https://api.github.com/repos/pfnet/chainer","labels_url":"https://api.github.com/repos/pfnet/chainer/issues/2787/labels{/name}","comments_url":"https://api.github.com/repos/pfnet/chainer/issues/2787/comments","events_url":"https://api.github.com/repos/pfnet/chainer/issues/2787/events","html_url":"https://github.com/pfnet/chainer/issues/2787","id":231978552,"number":2787,"title":"[v2] `Variable.__repr__` raises error when underlying data is not initialized","user":{"login":"delta2323","id":407052,"avatar_url":"https://avatars0.githubusercontent.com/u/407052?v=3","gravatar_id":"","url":"https://api.github.com/users/delta2323","html_url":"https://github.com/delta2323","followers_url":"https://api.github.com/users/delta2323/followers","following_url":"https://api.github.com/users/delta2323/following{/other_user}","gists_url":"https://api.github.com/users/delta2323/gists{/gist_id}","starred_url":"https://api.github.com/users/delta2323/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/delta2323/subscriptions","organizations_url":"https://api.github.com/users/delta2323/orgs","repos_url":"https://api.github.com/users/delta2323/repos","events_url":"https://api.github.com/users/delta2323/events{/privacy}","received_events_url":"https://api.github.com/users/delta2323/received_events","type":"User","site_admin":false},"labels":[{"id":485628084,"url":"https://api.github.com/repos/pfnet/chainer/labels/v2","name":"v2","color":"000000","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-05-29T09:57:15Z","updated_at":"2017-05-29T09:57:15Z","closed_at":null,"body":"The following code raises an error.\r\n\r\n```\r\nIn [1]: import chainer\r\nIn [2]: a = chainer.Variable()\r\nIn [3]: a.data\r\nIn [4]: a.data is None\r\nOut[4]: True\r\nIn [5]: repr(a)\r\n---------------------------------------------------------------------------\r\nAttributeError                            Traceback (most recent call last)\r\n<ipython-input-5-f35fccf361ee> in <module>()\r\n----> 1 repr(a)\r\n\r\n/Users/oonokenta/dev/chainer/chainer/variable.py in __repr__(self)\r\n    305 \r\n    306     def __repr__(self):\r\n--> 307         return variable_repr(self)\r\n    308 \r\n    309     def __str__(self):\r\n\r\n/Users/oonokenta/dev/chainer/chainer/variable.py in variable_repr(var)\r\n     75         prefix = 'variable'\r\n     76 \r\n---> 77     if arr.size > 0 or arr.shape == (0,):\r\n     78         lst = numpy.array2string(arr, None, None, None, ', ', prefix + '(')\r\n     79     else:  # show zero-length shape unless it is (0,)\r\n\r\nAttributeError: 'NoneType' object has no attribute 'size'\r\n```\r\n\r\nIt is because `variable_repr(var)` assumes that  `var.data` is not `None`.\r\n"}}
{"actor":{"display_login":"delta2323"}}