[GRASS-git] [OSGeo/grass] 66ca75: grass.exceptions: Do not translate exception text ...

Vaclav Petras noreply at github.com
Tue Sep 23 14:36:31 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: 66ca756b70ed481be172a4c1f1973f224510689c
      https://github.com/OSGeo/grass/commit/66ca756b70ed481be172a4c1f1973f224510689c
  Author: Vaclav Petras <wenzeslaus at gmail.com>
  Date:   2025-09-23 (Tue, 23 Sep 2025)

  Changed paths:
    M python/grass/exceptions/__init__.py

  Log Message:
  -----------
  grass.exceptions: Do not translate exception text (#6362)

CalledModuleError is trying hard to explain what is happening with several messages. In the past, we simply marked all messages for translation, so these were translatable as well. In past years, we started to not translate the messages raised in Python with the idea that this is consistent with Python exceptions and will generally be more appropriate in a traceback (discussed e.g. here #1559). As a side note, the current idea is that a user interface which is supposed to be localized, such as GUI, should generally provide its own messages. In the context of CalledModuleError, localized messages will be the messages provided by the tool which just failed, so they may be part of the traceback (but are also accessible separately if the exception is handled by the caller).

The new code does not translate the messages, so the translation mechanism does not need to work for the exception to be generated. This is extremely helpful in an interactive console and doctests where last result is assigned to a global variable named underscore, so any attempt to translate will end with an error: "TypeError: 'XY' object is not callable" where XY is whatever was the last line's type. Although the traceback originated still at the right top place in the code, the message was not useful and even misleading. Not translating now makes it work always without the current fragility or any other risk created by translations (even if we would address the specific issue of interaction with the underscore in interactive console and doctests).

This improves the interactive console user experience and doctest testing for grass.script, grass.pygrass, and grass.tools which all use CalledModuleError as well as for any functions which are using these (such as the other functions in grass.script).



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