From 0006259508c8308ef8545a4967f71c1f86890e73 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Fri, 1 Jul 2016 16:07:35 +0200 Subject: [PATCH] switched internal usage of cast_error exception to reference_cast_error --- include/pybind11/cast.h | 2 +- include/pybind11/common.h | 1 + include/pybind11/pybind11.h | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/pybind11/cast.h b/include/pybind11/cast.h index 4a0aa3570..4ba9e275d 100644 --- a/include/pybind11/cast.h +++ b/include/pybind11/cast.h @@ -254,7 +254,7 @@ public: template using cast_op_type = pybind11::detail::cast_op_type; operator type*() { return (type *) value; } - operator type&() { if (!value) throw cast_error(); return *((type *) value); } + operator type&() { if (!value) throw reference_cast_error(); return *((type *) value); } protected: typedef void *(*Constructor)(const void *stream); diff --git a/include/pybind11/common.h b/include/pybind11/common.h index 3075fb3c6..e06eac002 100644 --- a/include/pybind11/common.h +++ b/include/pybind11/common.h @@ -310,6 +310,7 @@ PYBIND11_RUNTIME_EXCEPTION(stop_iteration) PYBIND11_RUNTIME_EXCEPTION(index_error) PYBIND11_RUNTIME_EXCEPTION(value_error) PYBIND11_RUNTIME_EXCEPTION(cast_error) /// Thrown when pybind11::cast or handle::call fail due to a type casting error +PYBIND11_RUNTIME_EXCEPTION(reference_cast_error) /// Used internally [[noreturn]] PYBIND11_NOINLINE inline void pybind11_fail(const char *reason) { throw std::runtime_error(reason); } [[noreturn]] PYBIND11_NOINLINE inline void pybind11_fail(const std::string &reason) { throw std::runtime_error(reason); } diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 0a3ef1870..3d31b21df 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -387,7 +387,7 @@ protected: if ((kwargs_consumed == nkwargs || it->has_kwargs) && (nargs_ == it->nargs || it->has_args)) result = it->impl(it, args_, kwargs, parent); - } catch (cast_error &) { + } catch (reference_cast_error &) { result = PYBIND11_TRY_NEXT_OVERLOAD; }