Prevent addition of new fields to Swigged payloads #304
bbercoviciUspace
started this conversation in
General
Replies: 2 comments 1 reply
-
Howdy @bbercoviciUspace , thanks for sharing this. I came across this challenge myself recently trying to debug code, and turns out that the stand-alone message was being setup with a variable that had a small typo in it. I think in general this would be good, but we'll have to look at this deeper to make sure we don't get unexpected behaviors and issues. |
Beta Was this translation helpful? Give feedback.
0 replies
-
@bbercoviciUspace I think this would be a very important feature to have. Do you mind creating an issue on this? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
Basilisk prevents adding non-existing fields to swig-wrapped C and C++ modules, with C modules being C-structures exposed in Python. This is a sound behavior that is achieved by adding the following lines to the modules .i files.
These lines will replace the default
__setattr__
methods of the wrapped Python objects with a custom method checking first whether the to-be-set variable already exists in the object to be modified.However, there isn't such a mechanism in place for message payloads. One can try to create an instance of a msgPayload and add new fields from python without hurdle or warning.
I naively tried to add the same code block as before to
msgInterfacePy.i.in
and was able to compile Basilisk. I could then check that adding new fields to the payload was indeed forbidden.However, the unit tests are no longer passing due to improperly wrapped msg recorders. See the pytest trace below.
Freezing the msg payloads seems like a very desirable feature, but I guess there are other elements to consider in the trade off. What are your thoughts @patkenneally , @schaubh ?
Beta Was this translation helpful? Give feedback.
All reactions