-
Notifications
You must be signed in to change notification settings - Fork 750
Incorrect error place reported in python traceback #542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Oh, I see that this is caused by |
GetPreferredSize() here is an overload for virtual method of System.Windows.Forms.GroupBox class. It is called from .NET code inside self.Controls.Add() method of System.Windows.Forms.Form class. So callstack is: Python -> .NET ->Python GetPreferredSize(). It is really difficult to debug Python script with such traceback. Situation is slightly better if Exception was thrown - by changing in source "WinForms.GroupBox.GetPreferredSize" to "WinForms.GroupBox" I get:
Here I see at least method name "System.Windows.Forms._StagesGroup.GetPreferredSize" but also no line number. |
Valid line numbers for the C# code in a stacktrace could appears only if .dll files are paired with .pdb files. |
@dmitriyse @denfromufa Now, imagine python callback function got some interpreter error or exception. In this case PyObject_CallObject() returns NULL. Then pythonnet creates new exception object, isn't it ? But at the moment pythonnet doesn't save traceback, so not possible to localize the source of error. I think this can be improved. |
The Python method gets called via PyObject.Invoke in pyobject.cs (called from PythonDerivedType.InvokeMethod in classderived.cs). You could fetch the Python traceback in there and use that to add more information to the .net PythonException thrown. |
I think this is fixed now. |
Environment
Details
As we see, function GetPrefferedSize() got called. But stack traceback shows error in line 19 that is wrong. Bacause error is in line 14.
Minimal, Complete, and Verifiable example
this will help us understand the issue.
So why the error place is incorrect in traceback?
The text was updated successfully, but these errors were encountered: