Mailing List Archive

Embedded python is not 100% stable
Hi Python LIst,

I have been working on adding embedded python into OpenSCAD (
www.openscad.org)
for some time already. For that i coded/added an additional Python Type
Object
which means to hold openscad geometric data.

It works quite well but unfortunately its not 100% stable and i have been
heavily checking
all the functions which are referenced in the PyType Object and tried to
match
them with the documentation which i found in the python web site but now i
am stuck
and i cant progress any further
I am specially interested why the program constantly crashes when i
activate the lines 14 and 15
in pyopenscad.cc.
I have attached the two most relevant files and I would be happy if anybody
interested
could tell me, if there is an obvious bug popping into your eyes.
If anybody is interested to see the complete picture, all source code is
available checked in
in github @

https://github.com/gsohler/openscad.git branch "libfive"
Thank you for reading. Any spotted bug found will make me happy
--
https://mail.python.org/mailman/listinfo/python-list
Re: Embedded python is not 100% stable [ In reply to ]
Guenther Sohler wrote at 2023-4-13 09:40 +0200:
> ...
>I have been working on adding embedded python into OpenSCAD (
>www.openscad.org)
>for some time already. For that i coded/added an additional Python Type
>Object
>which means to hold openscad geometric data.
>
>It works quite well but unfortunately its not 100% stable and i have been
>heavily checking
>all the functions which are referenced in the PyType Object and tried to
>match
>them with the documentation which i found in the python web site

The Python C/C++ interface is complex: it is easy to make
mistakes which may lead to crashes.

Often, `cython` (--> PyPI) can help you to define extension types
in a much safer way. Maybe, you check its documentation?
--
https://mail.python.org/mailman/listinfo/python-list
Re: Embedded python is not 100% stable [ In reply to ]
On 4/13/23 03:40, Guenther Sohler wrote:
>

Attachments are stripped, so they weren't included.

Glancing at the branch and the 2 lines you mentioned.

You have a comment with a link for python 2.3 documentation.
Yet you have python 3.10 code included elsewhere (and openscad itself
requires the modern spec C++17, so I assume your aim is at current versions)

https://docs.python.org/3.10/extending/newtypes.html
is the equivalent doc for that.

I am not experienced in defining PyType objects in C, but notice
syntactical discrepancies, missing "static" on dealloc, use of
typecasted malloc rather than PyType_GenericAlloc()
https://docs.python.org/3.10/c-api/typeobj.html#c.PyTypeObject.tp_alloc

Without digging in deeper and learning more I can't say for certain
whether or not those are issues, but intuitively I assume they would be
and that the implementation needs to more closely mirror the syntactical
flow implementations of modern working examples..

--
https://mail.python.org/mailman/listinfo/python-list