bastibe / lunatic-python

A two-way bridge between Python and Lua
http://labix.org/lunatic-python
GNU Lesser General Public License v2.1
303 stars 83 forks source link

python properties are not handled properly #71

Closed marcelvanherk closed 4 years ago

marcelvanherk commented 4 years ago

Hi,

python properties are not handled properly, e.g. pydicom dataset.pixel_array returns nil. This is a property that should call a getter. Not sure how to implement it:

lua example:

pyd=python.import('pydicom') dataset = pyd.dcmread(filename) print(dataset.PatientName) --fails plt.imshow{dataset.pixel_array, cmap=plt.cm.bone} -- works python.globals().dataset=dataset plt.imshow{python.eval('dataset.pixel_array'), cmap=plt.cm.bone}

plt.show()

Marcel

marcelvanherk commented 4 years ago

Found it: change this: item = PyObject_GetItem(obj->o, key);

into

item = PyObject_GetItem(obj->o, key);
if (!item) item = PyObject_GetAttr(obj->o, key);

Fixes it!

Marcel

marcelvanherk commented 4 years ago

Is fixed in the merged version