Skip to content

Commit d40885a

Browse files
committed
clarified pickling docs
1 parent 3d0e6ff commit d40885a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/advanced.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,8 @@ looks as follows:
12251225
if (t.size() != 2)
12261226
throw std::runtime_error("Invalid state!");
12271227
1228-
/* Invoke the constructor (need to use in-place version) */
1228+
/* Invoke the in-place constructor. Note that this is needed even
1229+
when the object just has a trivial default constructor */
12291230
new (&p) Pickleable(t[0].cast<std::string>());
12301231
12311232
/* Assign any additional state */
@@ -1247,7 +1248,9 @@ An instance can now be pickled as follows:
12471248
12481249
Note that only the cPickle module is supported on Python 2.7. It is also
12491250
important to request usage of the highest protocol version using the ``-1``
1250-
argument to ``dumps``.
1251+
argument to ``dumps``. Failure to follow these two steps will lead to important
1252+
pybind11 memory allocation routines to be skipped during unpickling, which will
1253+
likely cause memory corruption and/or segmentation faults.
12511254

12521255
.. seealso::
12531256

0 commit comments

Comments
 (0)