[Binding] Improves of the setting of data field of type string.#174
Merged
damienmarchal merged 2 commits intosofa-framework:masterfrom Sep 16, 2021
Merged
Conversation
…ity with SofaPython2 With Sofapython3 it is not possible to set data's value from string: As it was possible in SofaPython2 This PR make that possible to ease the transition process. A deprecation message is added when using the added feature. A test is provided to validate the behavior.
… from invalid data type. The existing code to set a data field of type string from string was not correct. It was converting the python type to string which was leading to allowing things like that: object.name.value = ["Name"] print(object.name.value) # was printing '["Damien"]' This is not allowed anymore rising an exception returning the type of the objcet passed. object.name.value = ["Name"] [ERROR] [SofaPython3::SceneLoader] RuntimeError: trying to set value for 'name' from a python object of type <class 'list'>
2357201 to
b24ba75
Compare
Contributor
|
as par as we want, aka to be compatible with py2 code and throwing a deprecated message. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It is not possible to set data's value from string as it was possible in SofaPython2
This PR restore the SofaPython2 behavior to ease the transition process.
But, when using it, a deprecation message is now emitted.
A test is provided to validate the behavior.
Improve the exception returned when trying to set value from an invalid type.
This behavior is not correct and is the consequence of how we set the value for data of type 'string' value.
In the PR we don't allow this anymore by rising an exception.