Hello,
I am getting a memory exception when parsing numpy data buffers passed using the PyArg_ParseTuple() method. I am using C++Builder in 11.3. I updated my P4D yesterday, using the auto installer and code from the master repo. My code on the C++ end is:
PPyObject array1( PPyObject self, PPyObject args )
{
TPythonEngine * eng = GetPythonEngine();
unsigned int i1;
unsigned long num_points;
double * data;
int ret = eng->PyArg_ParseTuple(args,"y*",&data);
// copy data
num_points = python_interface::num_points;
for (i1=0; i1<num_points; i1++)
python_interface::test_array1[i1] = *(data+i1);
return eng->ReturnNone();
}
on the python side I have:
import numpy as np
import python_module
num_pts = 10
python_module.array_size(num_pts)
test_arr1 = np.linspace(1.0,10.0,num_pts,dtype=float)
python_module.array1(test_arr1.data)
test_arr2 = np.linspace(2.0,20.0,num_pts,dtype=float)
python_module.array2(test_arr2.data)
The data is passed fine, and the values are consistent. The exception occurs when the ReturnNone() call is made.
Project p4d.exe raise exception class $C0000005 with message 'access violation at 0x00c1d000: read of address 0x000000b8'.
Exception occurs regardless of whether or not data is copied.
The script does not continue pass this point, and returns the exception so the second array is never passed.
Any ideas? Please let me know if you need any other info, and any help would be appreciated.