Repository navigation
d.frame: Format fatal error messages with str.format - #7939
Merged
Merged
Conversation
Pass formatted error string to fatal() using str.format() instead of passing the exception object as a second argument, which was erroneously binding to the env parameter and causing unhandled AttributeError/TypeError. Fixes OSGeo#7937 Signed-off-by: bhuvan-somisetty <somisettybhuvan5@gmail.com>
echoix
approved these changes
Sep 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes calls to
fatal()inscripts/d.frame/d.frame.pywithinread_monitor_file()andwrite_monitor_file().Previously, the exception object
ewas passed as a second argument:fatal(_("Unable to get monitor info. %s"), e). Becausegrass.script.core.fatal()has the signaturefatal(msg, env=None), the second argument was binding toenvinstead of formatting the message, leaving the%splaceholder intact and causingerror()/run_command()to crash with an unhandledAttributeError(orTypeErrorinsubprocess) when treatingeas an environment mapping.The calls now use
str.format()per GRASS coding conventions:fatal(_("Unable to get monitor info. {}").format(e))Motivation and context
Fixes #7937
How has this been tested?
Tested
fatal()behavior withOSErrorexception handling in Python, verifying that the formatted error message is generated properly without raisingAttributeError/TypeErroronenv. Verified syntax and formatting withruff checkandruff format --check.Screenshots (if appropriate)
Types of changes
Checklist