-
Notifications
You must be signed in to change notification settings - Fork 192
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
force string type into str before escaping #3769
force string type into str before escaping #3769
Conversation
This came up in the context of 'manually' setting the parallelization settings of a AiiDA-QE workchain via the nk = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @DanielMarchand . It would be good to add some unit tests (I can help with this if you like) because the current implementation is not correct.
@@ -35,6 +35,7 @@ def escape_for_bash(str_to_escape): | |||
within triple quotes to make it work, getting finally: the complicated | |||
string found below. | |||
""" | |||
str_to_escape = str(str_to_escape) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if str_to_escape
is None
this will now return 'None'
i.e. the literal string 'None' which is not what we want. This should at the very least be moved after the conditional that checks for None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that would be great, its definitely a bit more subtle an issue than I thought it was...
So, for the tests, create a new file In there, use regular pytest syntax, e.g.
|
Superseded by #3873 |
It is very easy for a user to pass integers as arguments when a string is expected. In the current version, an exception that would be very cryptic to novel users occurs. Forcing a string type should be a harmless way of avoiding this error.
The returned error is