tpaviot / pythonocc-core

Python package for 3D geometry CAD/BIM/CAM
GNU Lesser General Public License v3.0
1.33k stars 374 forks source link

OSD::SetSignal() for Exception handling in Python #1295

Open jek28 opened 9 months ago

jek28 commented 9 months ago

Hi I am using pythonocc to read a step file thanks to the read_step_file function of the OCC.Extend.DataExchange module. In case of a corrupted file (e.g. missing references) the above function generates a crash in python without generating exceptions. I have already tried using a try-except statement without results.

I have read in the C++ documentation about the OSD::SetSignal() function (joined with OCC_CATCH_SIGNALS in linux) which is supposed to turn application kill signals into exceptions.

Searching the python library I have not found how to enable this feature and the program keeps crashing without exception. Does anyone know if these options are available?

tpaviot commented 7 months ago

pythonocc should catch all occt exceptions and raise a proper python exception. Thus, if python does not raise any exception, it is because of occt itself, and you should get a segfault. Can you please post a code snippet and the buggy step file?