Commit 00b8f365 by Dean Moldovan

Relax py::pickle() get/set type check

Fixes #1061.

`T` and `const T &` are compatible types.
parent 7939f4b3
...@@ -17,6 +17,9 @@ v2.2.1 (Not yet released) ...@@ -17,6 +17,9 @@ v2.2.1 (Not yet released)
* Fixed a regression where the ``py::keep_alive`` policy could not be applied * Fixed a regression where the ``py::keep_alive`` policy could not be applied
to constructors. `#1065 <https://github.com/pybind/pybind11/pull/1065>`_. to constructors. `#1065 <https://github.com/pybind/pybind11/pull/1065>`_.
* Relax overly strict ``py::picke()`` check for matching get and set types.
`#1064 <https://github.com/pybind/pybind11/pull/1064>`_.
v2.2.0 (August 31, 2017) v2.2.0 (August 31, 2017)
----------------------------------------------------- -----------------------------------------------------
......
...@@ -293,7 +293,7 @@ struct pickle_factory; ...@@ -293,7 +293,7 @@ struct pickle_factory;
template <typename Get, typename Set, template <typename Get, typename Set,
typename RetState, typename Self, typename NewInstance, typename ArgState> typename RetState, typename Self, typename NewInstance, typename ArgState>
struct pickle_factory<Get, Set, RetState(Self), NewInstance(ArgState)> { struct pickle_factory<Get, Set, RetState(Self), NewInstance(ArgState)> {
static_assert(std::is_same<RetState, ArgState>::value, static_assert(std::is_same<intrinsic_t<RetState>, intrinsic_t<ArgState>>::value,
"The type returned by `__getstate__` must be the same " "The type returned by `__getstate__` must be the same "
"as the argument accepted by `__setstate__`"); "as the argument accepted by `__setstate__`");
......
...@@ -115,7 +115,7 @@ TEST_SUBMODULE(pickling, m) { ...@@ -115,7 +115,7 @@ TEST_SUBMODULE(pickling, m) {
[](py::object self) { [](py::object self) {
return py::make_tuple(self.attr("value"), self.attr("extra"), self.attr("__dict__")); return py::make_tuple(self.attr("value"), self.attr("extra"), self.attr("__dict__"));
}, },
[](py::tuple t) { [](const py::tuple &t) {
if (t.size() != 3) if (t.size() != 3)
throw std::runtime_error("Invalid state!"); throw std::runtime_error("Invalid state!");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment