Skip to content

Ugly traceback in PythonException #1359

Description

@benoithudson

Environment

  • Pythonnet version: 2.5.0 and earlier
  • Python version: 3.7 and 2.7
  • Operating System: any
  • .NET Runtime: any

Details

  • Describe what you were trying to get done.

Within Unity, when a PythonException is thrown, we usually print the exception. It comes out looking like:

PythonException: TypeError : cannot create weak reference to 'PySideTestUI' object
['  File "<string>", line 3, in <module>/n', '  File "/Users/bhudson/projects/com.unity.scripting.python/com.unity.scripting.python/Samples/PySideExample/PySideExample.py", line 168, in create_or_reinitialize/n    _PYSIDE_UI = PySideTestUI()/n', '  File "/Users/bhudson/projects/com.unity.scripting.python/com.unity.scripting.python/Samples/PySideExample/PySideExample.py", line 54, in __init__/n    self._dialog = self.load_ui_widget(ui_path.replace("////", "/"))/n', '  File "/Users/bhudson/projects/com.unity.scripting.python/com.unity.scripting.python/Samples/PySideExample/PySideExample.py", line 130, in load_ui_widget/n    ui.useCameraButton.clicked.connect(self.use_camera)/n']

All on one line. It's very hard to read.

The pythonnet issue is that we have a list of strings that got str() called on it rather than joining them. Then a separate bug is that something is flipping backslashes to slashes but I don't think that's pythonnet's responsibility.

The reason is here: https://github.com/pythonnet/pythonnet/blob/master/src/runtime/pythonexception.cs#L53

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions