Closed sassy-asjp closed 2 months ago
Ah, I think is the same issue as #249
I wonder if the fix for the C message recorder, instead of refactoring out the __getattr__
usage in the Python side, we could force the creation of the recorder object into the C/C++ side, similar to how C++ message recorder works, which might fix the issue.
It would probably require C++ usage in src/architecture/messaging/msgAutoSource/cMsgCInterfacePy.i.in
, which I guess sounds fine?
@juan-g-bonilla , I think yo helped create this code. Any thoughts on this issue and potential solution?
This seems like a VSCode Python Debugger bug. We should try to make a minimal reproducible example without Basilisk to try and find exactly what’s triggering this. Then, if we confirm this is a VSCode Python Debugger bug, we should post an issue on their GitHub and ask for a fix. In the mean time, I’m not opposed to a quick fix on our side, but I’d rather fix/find the core issue if possible.
Regarding the proposed fix, it seems fine to me. I’d put the code that sets the proprieties in __init__
instead of clear
. Also, shame we lose the custom error message, but not the end of the world.
It does affect the native Python Pdb
debugger as well. I think it's a SWIG bug with the "proper" fix probably inside SWIG, though I don't really understand SWIG well enough to theorize about what could be going on.
I'll investigate a workaround for the C message recorder when I have time and submit it with the Python variable logger fix.
I submitted a merge request.
@juan-g-bonilla As noted on the merge request, the code to set the properties has to be put in clear
as it needs _variables
which won't be set until clear
Describe the bug
Usage of a C message
.recorder(timeDiff)
andPythonVariableLogger
cause mysterious debugger behavior:next
over usage in thePdb
will result in skipping to the next breakpoint, not over to the next line as expected.step
into the usage in thePdb
will result in infinite recursionTo reproduce
This script reproduces the issues
Expected behavior The debugger should work as expected, e.g., even with the lines uncommented, the VSCode debugger will hit a breakpoint placed on
print
.Screenshots N/A
Desktop (please complete the following information):
Additional context
It seems to be a weird interaction between SWIG, the debugger, and
__getattr__
. The infinite loop the Pdb gets trapped in is within__getattr__
as it constantly gets called trying to find a non-existent attribute. In the C message case, it is looking forthis
and in thePythonVariableLogger
case it is looking for_variables
.When I modify
PythonVariableLogger
to not use__getattr__
, the weirdness goes away. I can submit my change for this, however removing__getattr__
for the C message recorder case looks a lot less straightforward.If you run the offending line within the Pdb console, it will run fine. It is only broken when it's in the script the Pdb is being used to debug.
Potential fix for
PythonVariableLogger
: