Repository navigation
grass.gunittest: Add the module name as an exception note - #7689
Merged
Merged
Conversation
The test loader raised a new ImportError to say which module could not be imported. The message used e.message, which does not exist in Python 3, so the handler raised AttributeError instead of the intended error. Add the module name as a note to the original error instead. From the Python documentation of BaseException.add_note(): "Add the string note to the exception's notes which appear in the standard traceback after the exception string." The traceback then shows both the import error and the module name. Exception notes need Python 3.11, which is now the minimum version.
echoix
approved these changes
Jul 14, 2026
echoix
pushed a commit
to wenzeslaus/grass
that referenced
this pull request
Jul 14, 2026
The test loader raised a new ImportError to say which module could not be imported. The message used e.message, which does not exist in Python 3, so the handler raised AttributeError instead of the intended error. Add the module name as a note to the original error instead. From the Python documentation of BaseException.add_note(): Add the string note to the exception's notes which appear in the standard traceback after the exception string. The traceback then shows both the import error and the module name. Exception notes need Python 3.11, which is now the minimum version.
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.
Now, the test loader raises a new
ImportErrorto say which module could not be imported, but its message usese.message, which does not exist in Python 3. The handler therefore raisesAttributeErrorinstead of the intended error.Add the module name as a note to the original error instead. From the Python documentation of
BaseException.add_note(): "Add the stringnoteto the exception's notes which appear in the standard traceback after the exception string."The traceback then shows the import error and the module which could not be imported:
The error is not caught anywhere, so it reaches a traceback, which is where a note is shown. The handler is not reached now, because the
tryblock does not import the test module.Exception notes need Python 3.11, which is now the minimum version (discussed in #4032). This touches the same lines as #4032, so whichever is merged second needs a trivial conflict resolution.