[GRASS-git] [OSGeo/grass] 40e99f: grass.script: Raise, not fatal in create_project (...
Vaclav Petras
noreply at github.com
Fri Sep 26 12:30:29 PDT 2025
Branch: refs/heads/main
Home: https://github.com/OSGeo/grass
Commit: 40e99f661fd6c9cceabad800b9fcc2b4871cebe2
https://github.com/OSGeo/grass/commit/40e99f661fd6c9cceabad800b9fcc2b4871cebe2
Author: Vaclav Petras <wenzeslaus at gmail.com>
Date: 2025-09-26 (Fri, 26 Sep 2025)
Changed paths:
M python/grass/script/core.py
M python/grass/script/tests/grass_script_core_location_test.py
Log Message:
-----------
grass.script: Raise, not fatal in create_project (#6413)
The create_project function (and the create_location function) specify in the documentation that it raises ScriptError on error. However, in some cases it calls fatal instead leading to system exit (SystemExit exception) instead with the default settings. This changes the fatal call into raise so that it aligns with the documentation and with other places in the function which raise ScriptError. This also makes it to behave in a more expected way in standard Python workflow.
Current GRASS code already wraps the calls into try-except with ScriptError. In case of GUI, it checks the specific existence condition ahead of time.
The exception text is not translatable according to the our new practice for exceptions.
This also removes the warning when the project exists and overwrite is set to True. This is explicitly requested behavior, so warning not required. Additionally, while it kind of fit together with fatal with overwrite set to False, not it does not fit. Removing it also removes the need for a translatable string at that place which is often used with minimal setup during startup, so the result is simpler, less fragile code.
Tests now cover all combinations cases (does not exist, exists, with and without overwrite).
To unsubscribe from these emails, change your notification settings at https://github.com/OSGeo/grass/settings/notifications
More information about the grass-commit
mailing list