[C++-sig] Bug and patch for boost.pythonwithenable_shared_from_this
Nicolas Lelong
nico_ml at mgdesign.org
Fri Dec 12 15:55:16 CET 2008
FWIW, it seems I can't reproduce the problem with current boost svn trunk code, the problem still existed in boost_1_37_0 though. I could not spot the changes made that fixed the problem.
I took a look at the shared_ptr aliasing constructor, and made a patch to my boost_1_37_0 that solves the problem without altering shared_ptr code. All boost.python tests still pass after that. It may be useful to someone (the test case from Chad is attached)
--- python_1_37\converter\shared_ptr_from_python.hpp 2008-12-12 15:49:04.156250000 +0100
+++ python\converter\shared_ptr_from_python.hpp 2008-12-12 14:24:24.781250000 +0100
@@ -45,10 +45,14 @@
if (data->convertible == source)
new (storage) shared_ptr<T>();
else
+ {
+ boost::shared_ptr<void> hold_convertible_ref_count( (void*)0, shared_ptr_deleter(handle<>(borrowed(source))) );
+ // use aliasing constructor
new (storage) shared_ptr<T>(
- static_cast<T*>(data->convertible),
- shared_ptr_deleter(handle<>(borrowed(source)))
+ hold_convertible_ref_count,
+ static_cast<T*>(data->convertible)
);
+ }
data->convertible = storage;
}
---
to include the test in python test pass :
Index: libs/python/test/Jamfile.v2
===================================================================
--- libs/python/test/Jamfile.v2 (revision 72)
+++ libs/python/test/Jamfile.v2 (working copy)
@@ -75,6 +75,7 @@
[ bpl-test return_arg ]
[ bpl-test staticmethod ]
[ bpl-test shared_ptr ]
+[ bpl-test enable_shared_from_this ]
[ bpl-test andreas_beyer ]
[ bpl-test polymorphism ]
[ bpl-test polymorphism2 ]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20081212/7adda3e8/attachment-0001.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: enable_shared_from_this.cpp
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20081212/7adda3e8/attachment-0001.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: enable_shared_from_this.py
Type: application/octet-stream
Size: 600 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20081212/7adda3e8/attachment-0001.obj>
More information about the Cplusplus-sig
mailing list