[17.0][FIX] web_m2x_options_manager: safe_eval() ValueError#3388
Conversation
01aa68b to
f90423a
Compare
imlopes
left a comment
There was a problem hiding this comment.
It could be interesting to update tests to demonstrate what you are changing here.
SilvioC2C
left a comment
There was a problem hiding this comment.
Not blocking for such a minor fix, but could you please update the tests to include this case?
|
This PR has the |
|
@OCA/web-maintainers ping for an easy review and possibly merge? |
I chose to not update the test as they currently use @staticmethod
def _eval_node_options(node):
opt = node.attrib.get("options")
if opt:
return safe_eval(opt, nocopy=True)
return {} |
|
@vvrossem I think you have 2 options: Option 1You could update the test method to this: and then, in tests themselves, you can evaluate a node that contains Option 2At the very beginning of test method then, you can use these records to do the node's evaluation for you: and after the first check, you can update those options to override the attributes (as defined here: https://github.com/OCA/web/blob/17.0/web_m2x_options_manager/tests/test_m2x_create_edit_option.py#L30-L54). |
|
Hi @vvrossem thank you for your contribution! Could you please check the comments and reply/address them? |
``safe_eval()`` raises a ``ValueError`` when evaluating ``node`` options containing boolean values
written in lowercase (`true` or `false`).
Fixes
```
ValueError: <class 'NameError'>: "name 'true' is not defined" while evaluating
"{'<option_name>': [true|false}"
```
f90423a to
0277bdc
Compare
|
Hello, tests are updated. |
Nice, thank you for your contribution @vvrossem ! |
|
This PR looks fantastic, let's merge it! |
|
Congratulations, your PR was merged at d6b6880. Thanks a lot for contributing to OCA. ❤️ |
safe_eval()raises aValueErrorwhen evaluatingnodeoptions containing boolean values written in lowercase (trueorfalse).Fixes