<div dir="ltr">I will, thank you.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 4, 2016 at 1:14 PM, Stefan Seefeld <span dir="ltr"><<a href="mailto:stefan@seefeld.name" target="_blank">stefan@seefeld.name</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Matthew,<br>
<br>
would you mind submitting an issue on<br>
<a href="https://github.com/boostorg/python/issues" rel="noreferrer" target="_blank">https://github.com/boostorg/<wbr>python/issues</a> for this.<br>
<br>
Thanks,<br>
Stefan<br>
<div><div class="h5"><br>
On 04.08.2016 13:10, Matthew Conte wrote:<br>
> So I'm trying to create a boost python module that simply creates and<br>
> returns a numpy array,<br>
> but the function crashes (sometimes) and it doesn't ever seem to crash<br>
> on Python 2.<br>
><br>
> Here's the source code I made:<br>
><br>
> #include <boost/python.hpp><br>
> #include <numpy/ndarrayobject.h><br>
><br>
> using namespace boost::python;<br>
><br>
> object create_numpy_array() {<br>
> npy_intp dims = 1;<br>
> long* data = new long[1];<br>
> data[0] = 1;<br>
> PyObject* obj = PyArray_SimpleNewFromData(1, &dims, PyArray_LONGLTR,<br>
> data);<br>
> boost::python::handle<> handle(obj);<br>
> boost::python::numeric::array arr(handle);<br>
> return arr.copy();<br>
> }<br>
><br>
> BOOST_PYTHON_MODULE(create) {<br>
> import_array();<br>
> numeric::array::set_module_<wbr>and_type("numpy", "ndarray");<br>
> def("numpy_array", &create_numpy_array);<br>
> }<br>
><br>
><br>
> using a simple python script to test:<br>
><br>
> import create<br>
> print(create.numpy_array())<br>
><br>
><br>
> The stack trace indicates that the crash occurs on a<br>
> boost::python::handle destructor trying to decrease the ref count of a<br>
> PyObject with a ref count of 0.<br>
><br>
> I've tried this on both Windows 7 and Ubuntu 16.04 both 64-bit.<br>
><br>
> Thank you.<br>
><br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> Cplusplus-sig mailing list<br>
> <a href="mailto:Cplusplus-sig@python.org">Cplusplus-sig@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/cplusplus-sig" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/cplusplus-sig</a><br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
<br>
...ich hab' noch einen Koffer in Berlin...<br>
<br>
______________________________<wbr>_________________<br>
Cplusplus-sig mailing list<br>
<a href="mailto:Cplusplus-sig@python.org">Cplusplus-sig@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/cplusplus-sig" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/cplusplus-sig</a><br>
</font></span></blockquote></div><br></div>