recast std::bad_alloc as a Python exception

Will fix #111