{"action":"opened","issue":{"url":"https://api.github.com/repos/wjakob/pybind11/issues/55","labels_url":"https://api.github.com/repos/wjakob/pybind11/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/wjakob/pybind11/issues/55/comments","events_url":"https://api.github.com/repos/wjakob/pybind11/issues/55/events","html_url":"https://github.com/wjakob/pybind11/issues/55","id":124340469,"number":55,"title":"Type caster classes are not exception safe","user":{"login":"tmiasko","id":13466935,"avatar_url":"https://avatars.githubusercontent.com/u/13466935?v=3","gravatar_id":"","url":"https://api.github.com/users/tmiasko","html_url":"https://github.com/tmiasko","followers_url":"https://api.github.com/users/tmiasko/followers","following_url":"https://api.github.com/users/tmiasko/following{/other_user}","gists_url":"https://api.github.com/users/tmiasko/gists{/gist_id}","starred_url":"https://api.github.com/users/tmiasko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tmiasko/subscriptions","organizations_url":"https://api.github.com/users/tmiasko/orgs","repos_url":"https://api.github.com/users/tmiasko/repos","events_url":"https://api.github.com/users/tmiasko/events{/privacy}","received_events_url":"https://api.github.com/users/tmiasko/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-30T12:12:59Z","updated_at":"2015-12-30T12:12:59Z","closed_at":null,"body":"In general type casters for types that hold multiple values are not exception\r\nsafe during conversion from C++ to Python objects, for example:\r\n- std::pair, leaks o1 if first caster succeeds and second caster throws an exception\r\n- std::tuple, leaks already converted tuple elements if subsequent type caster throws an exception\r\n- argument casting in handle::call may leak partially converted arguments\r\n\r\nThe same is true of casters for std::vector, std::set, std::map.\r\n\r\nWhy those caster would throw an exception in a first place? There are a few\r\nplaces where explicit throw is used instead of null return value - I am not\r\nsure if those are accidental or there is supposed to be distinction between\r\nthose two situations? In addition, memory allocation in copy_constructor may\r\nthrow, or C++ copy constructor itself may throw an exception."}}