From fbec17ce900cf82da85570f435d24cae07aa6485 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Thu, 24 Nov 2016 12:30:11 +0100 Subject: [PATCH] error_already_set: move-only semantics --- include/pybind11/common.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/pybind11/common.h b/include/pybind11/common.h index e0ebedeaf..e0fa39223 100644 --- a/include/pybind11/common.h +++ b/include/pybind11/common.h @@ -475,6 +475,13 @@ public: error_already_set() : std::runtime_error(detail::error_string()) { PyErr_Fetch(&type, &value, &trace); } + + error_already_set(const error_already_set &) = delete; + + error_already_set(error_already_set &&e) + : std::runtime_error(e.what()), type(e.type), value(e.value), + trace(e.trace) { e.type = e.value = e.trace = nullptr; } + ~error_already_set() { Py_XDECREF(type); Py_XDECREF(value); Py_XDECREF(trace); } /// Give the error back to Python