Skip to content

d.frame: Format fatal error messages with str.format - #7939

Merged
echoix merged 1 commit into
OSGeo:mainfrom
bhuvan-somisetty:fix-d-frame-fatal-format
Sep 23, 2026
Merged

echoix merged 1 commit into
OSGeo:mainfrom
bhuvan-somisetty:fix-d-frame-fatal-format

Conversation

@bhuvan-somisetty

Copy link
Copy Markdown
Contributor

Description

This PR fixes calls to fatal() in scripts/d.frame/d.frame.py within read_monitor_file() and write_monitor_file().

Previously, the exception object e was passed as a second argument: fatal(_("Unable to get monitor info. %s"), e). Because grass.script.core.fatal() has the signature fatal(msg, env=None), the second argument was binding to env instead of formatting the message, leaving the %s placeholder intact and causing error() / run_command() to crash with an unhandled AttributeError (or TypeError in subprocess) when treating e as 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 with OSError exception handling in Python, verifying that the formatted error message is generated properly without raising AttributeError/TypeError on env. Verified syntax and formatting with ruff check and ruff format --check.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as before)

Checklist

  • PR title provides summary of the changes and starts with one of the pre-defined prefixes
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

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>
@github-actions github-actions Bot added Python Related code is in Python module display labels Sep 23, 2026
@echoix
echoix enabled auto-merge (squash) September 23, 2026 13:56
@echoix
echoix merged commit 31d4638 into OSGeo:main Sep 23, 2026
26 of 27 checks passed
@github-actions github-actions Bot added this to the 8.6.0 milestone Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

display module Python Related code is in Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] d.frame: fatal() called with format arguments passes exception to env parameter, causing unhandled AttributeError/TypeError

2 participants