From 00b8f3655dafe32ae04e05212a5a2aa1e2a0d16a Mon Sep 17 00:00:00 2001 From: Dean Moldovan Date: Mon, 4 Sep 2017 23:46:11 +0200 Subject: [PATCH] Relax py::pickle() get/set type check Fixes #1061. `T` and `const T &` are compatible types. --- docs/changelog.rst | 3 +++ include/pybind11/detail/init.h | 2 +- tests/test_pickling.cpp | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index b9d630d64..b4eecab58 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -17,6 +17,9 @@ v2.2.1 (Not yet released) * Fixed a regression where the ``py::keep_alive`` policy could not be applied to constructors. `#1065 `_. +* Relax overly strict ``py::picke()`` check for matching get and set types. + `#1064 `_. + v2.2.0 (August 31, 2017) ----------------------------------------------------- diff --git a/include/pybind11/detail/init.h b/include/pybind11/detail/init.h index deace19c0..c3594a190 100644 --- a/include/pybind11/detail/init.h +++ b/include/pybind11/detail/init.h @@ -293,7 +293,7 @@ struct pickle_factory; template struct pickle_factory { - static_assert(std::is_same::value, + static_assert(std::is_same, intrinsic_t>::value, "The type returned by `__getstate__` must be the same " "as the argument accepted by `__setstate__`"); diff --git a/tests/test_pickling.cpp b/tests/test_pickling.cpp index 821462ac4..9dc63bda3 100644 --- a/tests/test_pickling.cpp +++ b/tests/test_pickling.cpp @@ -115,7 +115,7 @@ TEST_SUBMODULE(pickling, m) { [](py::object self) { return py::make_tuple(self.attr("value"), self.attr("extra"), self.attr("__dict__")); }, - [](py::tuple t) { + [](const py::tuple &t) { if (t.size() != 3) throw std::runtime_error("Invalid state!");