-
-
Notifications
You must be signed in to change notification settings - Fork 301
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
[Bug] bugs introduced with cc6dbeb in pythonlib #339
Comments
Copied over from #333 for context:
There was a thorough discussion about the desired behavior of run_command() between 7.0 and 7.2 which is recorded in the Trac Ticket 2326. However, a return value is unexpected to Python programmers as exceptions are the usual error reporting mechanism in Python and thus dangerous because you could easily write code which was not checking anything and the error would appear only later. With interactive use, it is also awkward as you get 0 for every successfully executed line which is strange to Python users (not necessary even aware of process returncodes where Glynn addressed the different use cases (Python-like, immediate fail okay, error expected, more handling needed) by implementing the universal The case above, when None of the compatibility concerns should be relevant now as we are switching the major version and the proper on-error behavior was already in place since 7.2 (backported to 7.0), so if script used the defaults and was tested for errors in any way the exception would be generated (which is what happened on couple places in GRASS GIS, if I remember correctly, even after trying to address it beforehand, so it seems that the approach worked). Consequently, The same applies also to And yes, cc6dbeb assumes master is or will be 8.0, i.e., no other release from master before 8.0. Bug history investigation: As for
I agree with the change [in #333]. Besides fixing the issue, I think it is actually implementing the originally intended behavior. With |
[Moving from #333:]
I think there are other reasons for 7.8 being followed by 8.0. This is just an additional one. However, in this case, it just a formality and it could be introduced even without a major version since all code written after 7.2 which properly handles errors will continue to work. Anyway, the The current state is an inconsistent interface which keeps badly written code working. The new interface (with #333 fix and additional updates) better aligns with what Python users/programmers/script authors expect, so it is helpful for the beginners and people who are using more packages than just GRASS GIS. So, I would say it is at least somewhat important. Alternative solution is to keep the whatever state of |
It seems reasonable that by default handle_errors() returns None instead of returncode 0, and if returncode is not 0, raise an exception. IMHO, this does not require an increase of the major version. E.g. the change in TGIS introducing band reference was much more substantial, breaking pretty much all t.* modules. Regarding handle_errors(), it would be great if both the documentation and the code match the intended behaviour. If you think the current code is badly written, please provide either a PR or suggestions on how to improve. |
Removing the 7.0.0 backwards compatibility from run_command() which was raising exception on error but returning 0 on success. Adding option to use the standard fatal() error handling which might be good for use within GRASS GIS code itself. Adding extensive documentation for the available options and linking all relevant functions. Also passing module name explicitelly to CalledModuleError as a parameter.
Fixed by #1839. |
Describe the bug
The behaviour of
handle_errors()
in lib/python/script/core.py changed with cc6dbeb for no apparent reason, introducing several bugs.To Reproduce
See bug fixed by #333.
Expected behavior
A clear and concise description of what has changed and why it was changed. The code and the documentation should match.
Additional context
@wenzeslaus @landam
Regarding the changes introduced with cc6dbeb to
handle_errors()
, the priority of the errors value is not clear and the code does not conform to the documentation. Possible values are apparently "raise", "fatal", "status", "exit", and "ignore", default is "raise". Those errors values independent of the returncode must come first: status, exit, ignore. After that, if the returncode is not 0, the errors values "raise", "fatal", "ignore" must be handled, "raise" will apparently be used if the errors value is not set. At the end,handle_errors()
can return result or None for returncode == 0.What is the reason for
versionchanged:: 8.0
? Why would returning None instead of 0 be better in case ofreturncode == 0
?The text was updated successfully, but these errors were encountered: