Repository navigation
Conversation
Node.warn asserted that get_fslocation_from_item returned a non-None lineno, but non-Python items that do not override reportinfo() report None, so calling node.warn() raised AssertionError. Fall back to lineno 0 (consistent with the -1 sentinel used by get_fslocation_from_item) so the warning is emitted normally.
Author
|
Disclosure note: this PR was diagnosed and implemented with the help of an AI coding agent; I verified the diagnosis, ran the regression test red-then-green locally (test_nodes.py 16 passed, related suites 183 passed), and applied the repo's ruff lint/format checks myself. Apologies for not stating this in the original description - #15359's closure made the expectation explicit, and I've adopted it. The fix itself stands as reviewed: |
This branch has not been deployed
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.
Node.warn()crashes withAssertionErrorwhen called on a non-Python item that does not overridereportinfo().The default
reportinfo()returns(self.path, None, ""), soget_fslocation_from_item()yieldslineno=None.Node.warn()then hitsassert lineno is not Noneand raises, preventing the warning from being emitted at all.This affects custom/non-Python test items (documented in Non-Python tests) that call
self.warn()duringruntest()or collection.The fix removes the assertion and falls back to
lineno=0whenlineno is None, consistent with the existing-1sentinel used byget_fslocation_from_item()(which becomes0after the+1adjustment). This matches the approach already accepted in #14855 for a similarNonelineno issue inreports.py.A regression test adds a custom
.customitem with defaultreportinfo()that callsself.warn()inruntest(), verifying the warning is emitted normally instead of crashing.