{"action":"created","issue":{"url":"https://api.github.com/repos/ipython/ipython/issues/8564","labels_url":"https://api.github.com/repos/ipython/ipython/issues/8564/labels{/name}","comments_url":"https://api.github.com/repos/ipython/ipython/issues/8564/comments","events_url":"https://api.github.com/repos/ipython/ipython/issues/8564/events","html_url":"https://github.com/ipython/ipython/issues/8564","id":90323843,"number":8564,"title":"Autoreload error when running a script","user":{"login":"jewfro-cuban","id":10496371,"avatar_url":"https://avatars.githubusercontent.com/u/10496371?v=3","gravatar_id":"","url":"https://api.github.com/users/jewfro-cuban","html_url":"https://github.com/jewfro-cuban","followers_url":"https://api.github.com/users/jewfro-cuban/followers","following_url":"https://api.github.com/users/jewfro-cuban/following{/other_user}","gists_url":"https://api.github.com/users/jewfro-cuban/gists{/gist_id}","starred_url":"https://api.github.com/users/jewfro-cuban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jewfro-cuban/subscriptions","organizations_url":"https://api.github.com/users/jewfro-cuban/orgs","repos_url":"https://api.github.com/users/jewfro-cuban/repos","events_url":"https://api.github.com/users/jewfro-cuban/events{/privacy}","received_events_url":"https://api.github.com/users/jewfro-cuban/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-06-23T08:28:30Z","updated_at":"2015-06-24T09:01:50Z","closed_at":null,"body":"When running a script I get an error:\r\n```python\r\nError in callback <bound method AutoreloadMagics.post_execute_hook of <autoreload.AutoreloadMagics object at 0x00000000045E1B70>> (for post_execute):\r\n---------------------------------------------------------------------------\r\nAttributeError                            Traceback (most recent call last)\r\nC:\\<path_to_env>\\lib\\site-packages\\IPython\\extensions\\autoreload.py in post_execute_hook(self)\r\n    523         newly_loaded_modules = set(sys.modules) - self.loaded_modules\r\n    524         for modname in newly_loaded_modules:\r\n--> 525             _, pymtime = self._reloader.filename_and_mtime(sys.modules[modname])\r\n    526             if pymtime is not None:\r\n    527                 self._reloader.modules_mtimes[modname] = pymtime\r\n\r\nC:\\<path_to_env>\\lib\\site-packages\\IPython\\extensions\\autoreload.py in filename_and_mtime(self, module)\r\n    188\r\n    189         # if hasattr(module, '__name__'):\r\n--> 190         if module.__name__ == '__main__':\r\n    191             # we cannot reload(__main__)\r\n    192             return None, None\r\n\r\nAttributeError: 'module' object has no attribute '__name__'\r\n```\r\n\r\nI've fixed it locally with:\r\n```python\r\n        if hasattr(module, '__name__'):\r\n            if module.__name__ == '__main__':\r\n                # we cannot reload(__main__)\r\n                return None, None\r\n```\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ipython/ipython/issues/comments/114793661","html_url":"https://github.com/ipython/ipython/issues/8564#issuecomment-114793661","issue_url":"https://api.github.com/repos/ipython/ipython/issues/8564","id":114793661,"user":{"login":"Carreau","id":335567,"avatar_url":"https://avatars.githubusercontent.com/u/335567?v=3","gravatar_id":"","url":"https://api.github.com/users/Carreau","html_url":"https://github.com/Carreau","followers_url":"https://api.github.com/users/Carreau/followers","following_url":"https://api.github.com/users/Carreau/following{/other_user}","gists_url":"https://api.github.com/users/Carreau/gists{/gist_id}","starred_url":"https://api.github.com/users/Carreau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Carreau/subscriptions","organizations_url":"https://api.github.com/users/Carreau/orgs","repos_url":"https://api.github.com/users/Carreau/repos","events_url":"https://api.github.com/users/Carreau/events{/privacy}","received_events_url":"https://api.github.com/users/Carreau/received_events","type":"User","site_admin":false},"created_at":"2015-06-24T09:01:50Z","updated_at":"2015-06-24T09:01:50Z","body":"Great ! Will review !\r\n\r\nTip : When you commit, you can also add in the commit message [`fixes #8564`](https://help.github.com/articles/closing-issues-via-commit-messages/#closing-an-issue-in-the-same-repository) , when you push on github it will automatically link the PR (Pull Request) and the target issue. Then when the PR is merged it will auto close the issue !"}}