{"action":"opened","issue":{"url":"https://api.github.com/repos/DRMacIver/hypothesis/issues/68","labels_url":"https://api.github.com/repos/DRMacIver/hypothesis/issues/68/labels{/name}","comments_url":"https://api.github.com/repos/DRMacIver/hypothesis/issues/68/comments","events_url":"https://api.github.com/repos/DRMacIver/hypothesis/issues/68/events","html_url":"https://github.com/DRMacIver/hypothesis/issues/68","id":72472416,"number":68,"title":"Map and flatmap fail on functions without names","user":{"login":"saulshanabrook","id":1186124,"avatar_url":"https://avatars.githubusercontent.com/u/1186124?v=3","gravatar_id":"","url":"https://api.github.com/users/saulshanabrook","html_url":"https://github.com/saulshanabrook","followers_url":"https://api.github.com/users/saulshanabrook/followers","following_url":"https://api.github.com/users/saulshanabrook/following{/other_user}","gists_url":"https://api.github.com/users/saulshanabrook/gists{/gist_id}","starred_url":"https://api.github.com/users/saulshanabrook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saulshanabrook/subscriptions","organizations_url":"https://api.github.com/users/saulshanabrook/orgs","repos_url":"https://api.github.com/users/saulshanabrook/repos","events_url":"https://api.github.com/users/saulshanabrook/events{/privacy}","received_events_url":"https://api.github.com/users/saulshanabrook/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-01T16:47:55Z","updated_at":"2015-05-01T16:47:55Z","closed_at":null,"body":"Not all functions have the `__name__` attribute, but `map` and `flatmap` will crash if the function does not.\r\n\r\nFor example, if you wrap a function with `itertools.partial` the result will not have a `__name__` and so cannot be used in `map`.\r\n\r\n```\r\n$ python3\r\nPython 3.4.0 (default, Apr 11 2014, 13:05:11)\r\n[GCC 4.8.2] on linux\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> from hypothesis import given, assume, strategy\r\n>>> func = lambda a, b: a+b\r\n>>> import functools\r\n>>> func_wrapped = functools.partial(func, 10)\r\n>>> func_wrapped(1)\r\n11\r\n>>> func_wrapped(10)\r\n20\r\n>>> strategy(int).map(func_wrapped)\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/usr/local/lib/python3.4/dist-packages/hypothesis/searchstrategy/strategies.py\", line 533, in __repr__\r\n    self.mapped_strategy, self.pack.__name__\r\nAttributeError: 'functools.partial' object has no attribute '__name__'\r\n```"}}