-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Replace @assert with throw() in winprompt() #30639
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
Conversation
yuyichao
left a comment
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.
stdcall has nothing to do with return type.
|
Yichao. Thanks for the information. I only checked https://docs.julialang.org/en/v1/base/c/#ccall |
|
According to its documentation, this function can only fail if the buffer is too small. Do we have a reason to believe 1024 is always enough? If so, then the existing assertion is actually correct. (Either way though, if this happens it's our bug, since there's nothing the user/caller can do to get a bigger buffer.) |
|
Also, when the function fails it updates the length argument to tell you how much space is needed. So an alternative fix is to handle that case and retry the call with a bigger buffer, after which an assertion would be warranted. |
|
I think retrying the call with a bigger buffer is a good choice to make the code more solid, but if it fails again, we need to raise an exception rather than insert an assertion, because the outcome of the call depends on the response of an external program. If Julia allows @Assert to be deactivated in the future, the critical check can be bypassed. |
|
#38828 addresses resizing the buffer in case of failure |
Wondering why the extra argument bug was not caught by tests. If it is missing in tests, can I have your help to add a unit test for winprompt()?