Skip to content

Handling python exceptions #106

@jnbrunet

Description

@jnbrunet

The discussion started in #92 .

The following scene will behave differently either we are using SofaPython(2) or SofaPython3:

Test scene

# test.py
def createScene(root)
    root = '2' + 2

Using SofaPython(2):

[ERROR]   [PythonScript] TypeError: cannot concatenate 'str' and 'int' objects
  File "test.py", line 2, in createScene
    root = '2' + 2

Using SofaPython3:

[ERROR]   [SofaPython3::SceneLoader] TypeError: can only concatenate str (not "int") to str

At:
  test.py(2): createScene

In order to have the same behavior, we would have to place an exception hook in python interpreter of the plugin SofaPython3. However, this was not possible before python 3.8:

@damienmarchal in #92
I think there is two issue mixed together.
One is about the exception risen from python. In SofaPython they were catched by a dedicated hook installed by Sofa in the python interpreter. Because of multithreading this feature was broken before 3.8 and thus SofPython3 was not using it. The consequence is that when there is an error at the python level the behavior is different.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions