{"action":"created","issue":{"url":"https://api.github.com/repos/uqfoundation/dill/issues/120","labels_url":"https://api.github.com/repos/uqfoundation/dill/issues/120/labels{/name}","comments_url":"https://api.github.com/repos/uqfoundation/dill/issues/120/comments","events_url":"https://api.github.com/repos/uqfoundation/dill/issues/120/events","html_url":"https://github.com/uqfoundation/dill/issues/120","id":98286627,"number":120,"title":"pickle of certain modules fail on builtins with recurse=True","user":{"login":"mmckerns","id":321534,"avatar_url":"https://avatars.githubusercontent.com/u/321534?v=3","gravatar_id":"","url":"https://api.github.com/users/mmckerns","html_url":"https://github.com/mmckerns","followers_url":"https://api.github.com/users/mmckerns/followers","following_url":"https://api.github.com/users/mmckerns/following{/other_user}","gists_url":"https://api.github.com/users/mmckerns/gists{/gist_id}","starred_url":"https://api.github.com/users/mmckerns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmckerns/subscriptions","organizations_url":"https://api.github.com/users/mmckerns/orgs","repos_url":"https://api.github.com/users/mmckerns/repos","events_url":"https://api.github.com/users/mmckerns/events{/privacy}","received_events_url":"https://api.github.com/users/mmckerns/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/uqfoundation/dill/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-30T23:35:52Z","updated_at":"2015-07-30T23:42:40Z","closed_at":null,"body":"Another very odd corner case… looks like something with missing references to `builtins`\r\n\r\n```\r\nPython 3.4.3 (default, May 25 2015, 18:57:37) \r\n[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> import dill\r\n>>> dill.settings['recurse'] = True\r\n>>> import sys\r\n>>> import test_nested as module\r\n>>> module.a = 1234\r\n>>> pik_mod = dill.dumps(module)\r\n>>> module.a = 0\r\n>>> del sys.modules[module.__name__]\r\n>>> del module\r\n>>> module = dill.loads(pik_mod)\r\n>>> module.a \r\n1234\r\n>>> del sys.modules[module.__name__]\r\n>>> del module\r\n>>> \r\n>>> import test_mixins as module\r\n>>> module.a = 1234\r\n>>> pik_mod = dill.dumps(module)\r\n>>> module.a = 0\r\n>>> del sys.modules[module.__name__]\r\n>>> del module\r\n>>> module = dill.loads(pik_mod)\r\n(<class 'AttributeError'>, AttributeError(\"'module' object has no attribute 'vars'\",), <traceback object at 0x10ea637c8>)\r\n<function _get_attr at 0x10dd38ae8> (<module 'test_mixins' from '/Users/mmckerns/dev/svn/pathos/dill/tests/test_mixins.py'>, 'vars')\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/Users/mmckerns/lib/python3.4/site-packages/dill-0.2.4.dev0-py3.4.egg/dill/dill.py\", line 209, in loads\r\n    return load(file)\r\n  File \"/Users/mmckerns/lib/python3.4/site-packages/dill-0.2.4.dev0-py3.4.egg/dill/dill.py\", line 199, in load\r\n    obj = pik.load()\r\n  File \"/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/pickle.py\", line 1038, in load\r\n    dispatch[key[0]](self)\r\n  File \"/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/pickle.py\", line 1384, in load_reduce\r\n    value = func(*args)\r\n  File \"/Users/mmckerns/lib/python3.4/site-packages/dill-0.2.4.dev0-py3.4.egg/dill/dill.py\", line 661, in _get_attr\r\n    return getattr(self, name)\r\nAttributeError: 'module' object has no attribute 'vars'\r\n```"},"comment":{"url":"https://api.github.com/repos/uqfoundation/dill/issues/comments/126522366","html_url":"https://github.com/uqfoundation/dill/issues/120#issuecomment-126522366","issue_url":"https://api.github.com/repos/uqfoundation/dill/issues/120","id":126522366,"user":{"login":"mmckerns","id":321534,"avatar_url":"https://avatars.githubusercontent.com/u/321534?v=3","gravatar_id":"","url":"https://api.github.com/users/mmckerns","html_url":"https://github.com/mmckerns","followers_url":"https://api.github.com/users/mmckerns/followers","following_url":"https://api.github.com/users/mmckerns/following{/other_user}","gists_url":"https://api.github.com/users/mmckerns/gists{/gist_id}","starred_url":"https://api.github.com/users/mmckerns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmckerns/subscriptions","organizations_url":"https://api.github.com/users/mmckerns/orgs","repos_url":"https://api.github.com/users/mmckerns/repos","events_url":"https://api.github.com/users/mmckerns/events{/privacy}","received_events_url":"https://api.github.com/users/mmckerns/received_events","type":"User","site_admin":false},"created_at":"2015-07-30T23:42:40Z","updated_at":"2015-07-30T23:42:40Z","body":"The above works with most other modules, so it seems to be directly coming from `test_mixins`.\r\n```\r\nPython 3.4.3 (default, May 25 2015, 18:57:37) \r\n[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> import dill\r\n>>> dill.settings['recurse'] = True\r\n>>> def quad(a=1, b=1, c=0):\r\n...   inverted = [False]\r\n...   def invert():\r\n...     inverted[0] = not inverted[0]\r\n...   def dec(f):\r\n...     def func(*args, **kwds):\r\n...       x = f(*args, **kwds)\r\n...       if inverted[0]: x = -x\r\n...       return a*x**2 + b*x + c\r\n...     func.__wrapped__ = f\r\n...     func.invert = invert\r\n...     return func\r\n...   return dec\r\n... \r\n>>> @quad(a=0,b=2)\r\n... def double_add(*args):\r\n...   return sum(args)\r\n... \r\n>>> fx = sum([1,2,3])\r\n>>> assert double_add(1,2,3) == 2*fx\r\n>>> double_add.invert()\r\n>>> assert double_add(1,2,3) == -2*fx\r\n>>> _d = dill.copy(double_add)\r\n(<class 'AttributeError'>, AttributeError(\"'module' object has no attribute 'sum'\",), <traceback object at 0x1053cdb48>)\r\n<function _get_attr at 0x1046c9ae8> (<module '__main__' (<_frozen_importlib.SourceFileLoader object at 0x104331c88>)>, 'sum')\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/Users/mmckerns/lib/python3.4/site-packages/dill-0.2.4.dev0-py3.4.egg/dill/dill.py\", line 159, in copy\r\n    return loads(dumps(obj, *args, **kwds))\r\n  File \"/Users/mmckerns/lib/python3.4/site-packages/dill-0.2.4.dev0-py3.4.egg/dill/dill.py\", line 209, in loads\r\n    return load(file)\r\n  File \"/Users/mmckerns/lib/python3.4/site-packages/dill-0.2.4.dev0-py3.4.egg/dill/dill.py\", line 199, in load\r\n    obj = pik.load()\r\n  File \"/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/pickle.py\", line 1038, in load\r\n    dispatch[key[0]](self)\r\n  File \"/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/pickle.py\", line 1384, in load_reduce\r\n    value = func(*args)\r\n  File \"/Users/mmckerns/lib/python3.4/site-packages/dill-0.2.4.dev0-py3.4.egg/dill/dill.py\", line 661, in _get_attr\r\n    return getattr(self, name)\r\nAttributeError: 'module' object has no attribute 'sum'\r\n```"}}