Skip to content

Commit 72a2aec

Browse files
committed
fix: use original dict
Signed-off-by: Henry Schreiner <[email protected]>
1 parent c5dc6f9 commit 72a2aec

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

include/pybind11/detail/init.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,10 @@ void setstate(value_and_holder &v_h, std::pair<T, O> &&result, bool need_alias)
451451
// See PR #2972 for details.
452452
return;
453453
}
454-
setattr((PyObject *) v_h.inst, "__dict__", d);
454+
auto dict = getattr((PyObject *) v_h.inst, "__dict__");
455+
if (PyDict_Update(dict.ptr(), d.ptr()) < 0) {
456+
throw error_already_set();
457+
}
455458
}
456459

457460
/// Implementation for py::pickle(GetState, SetState)

0 commit comments

Comments
 (0)