{"action":"created","issue":{"url":"https://api.github.com/repos/ipython/ipython/issues/10214","repository_url":"https://api.github.com/repos/ipython/ipython","labels_url":"https://api.github.com/repos/ipython/ipython/issues/10214/labels{/name}","comments_url":"https://api.github.com/repos/ipython/ipython/issues/10214/comments","events_url":"https://api.github.com/repos/ipython/ipython/issues/10214/events","html_url":"https://github.com/ipython/ipython/issues/10214","id":203816777,"number":10214,"title":"Fix for infinite recursion in autoreload","user":{"login":"mccullerlp","id":413939,"avatar_url":"https://avatars1.githubusercontent.com/u/413939?v=4","gravatar_id":"","url":"https://api.github.com/users/mccullerlp","html_url":"https://github.com/mccullerlp","followers_url":"https://api.github.com/users/mccullerlp/followers","following_url":"https://api.github.com/users/mccullerlp/following{/other_user}","gists_url":"https://api.github.com/users/mccullerlp/gists{/gist_id}","starred_url":"https://api.github.com/users/mccullerlp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mccullerlp/subscriptions","organizations_url":"https://api.github.com/users/mccullerlp/orgs","repos_url":"https://api.github.com/users/mccullerlp/repos","events_url":"https://api.github.com/users/mccullerlp/events{/privacy}","received_events_url":"https://api.github.com/users/mccullerlp/received_events","type":"User","site_admin":false},"labels":[{"id":462276554,"url":"https://api.github.com/repos/ipython/ipython/labels/Need%20Contributor","name":"Need Contributor","color":"0e8a16","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2017-01-28T16:43:42Z","updated_at":"2017-11-20T16:33:21Z","closed_at":null,"author_association":"NONE","body":"I have a class which memoizes contains a link to itself as an attribute. This is used as a to ensure that a class specific memoized computation is unique and not inherited from bases.\r\n\r\nIt turns out that this causes an infinite recursion between update_generic and update_class in autoreload.\r\n\r\nThis is fixed with a quick check to prevent this case. added after the \"prevent recursion\" comment.\r\n\r\nFurthermore in this code, the for loop also loops on \"new\" object attributes, which will fix #8771\r\n\r\n```python\r\ndef update_class(old, new):\r\n    \"\"\"Replace stuff in the __dict__ of a class, and upgrade\r\n    method code objects\"\"\"\r\n    #for key in list(old.__dict__.keys()):\r\n    for key in set(list(old.__dict__.keys()) + list(new.__dict__.keys())):\r\n        old_obj = getattr(old, key)\r\n\r\n        try:\r\n            new_obj = getattr(new, key)\r\n        except AttributeError:\r\n            # obsolete attribute: remove it\r\n            try:\r\n                delattr(old, key)\r\n            except (AttributeError, TypeError):\r\n                pass\r\n            continue\r\n\r\n        #prevent recursion \r\n        if old_obj not in [old, new] and new_obj not in [old, new]:\r\n            if update_generic(old_obj, new_obj): continue\r\n\r\n        try:\r\n            setattr(old, key, getattr(new, key))\r\n        except (AttributeError, TypeError):\r\n            pass # skip non-writable attributes\r\n```\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ipython/ipython/issues/comments/345750931","html_url":"https://github.com/ipython/ipython/issues/10214#issuecomment-345750931","issue_url":"https://api.github.com/repos/ipython/ipython/issues/10214","id":345750931,"user":{"login":"fenwickipedia","id":10800967,"avatar_url":"https://avatars1.githubusercontent.com/u/10800967?v=4","gravatar_id":"","url":"https://api.github.com/users/fenwickipedia","html_url":"https://github.com/fenwickipedia","followers_url":"https://api.github.com/users/fenwickipedia/followers","following_url":"https://api.github.com/users/fenwickipedia/following{/other_user}","gists_url":"https://api.github.com/users/fenwickipedia/gists{/gist_id}","starred_url":"https://api.github.com/users/fenwickipedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fenwickipedia/subscriptions","organizations_url":"https://api.github.com/users/fenwickipedia/orgs","repos_url":"https://api.github.com/users/fenwickipedia/repos","events_url":"https://api.github.com/users/fenwickipedia/events{/privacy}","received_events_url":"https://api.github.com/users/fenwickipedia/received_events","type":"User","site_admin":false},"created_at":"2017-11-20T16:33:21Z","updated_at":"2017-11-20T16:33:21Z","author_association":"NONE","body":"Thanks @takluyver that ran with no recursion issue in 6.x, will try 5.x in a Py3 and Py2.7 env to see if it recreates."}}
{"actor":{"display_login":"fenwickipedia"}}