Conversation
`unserialize_warning_message` resolved the message class with `importlib.import_module` and a `getattr`, both outside every guard and both in the controller's receiver thread. Anything they raised killed that thread: the node went down mid-test and the run failed in the scheduler with `KeyError: <WorkerController gwN>`, two steps away and naming nothing that led back to the import. This is GH#404, open since 2019. Its 2022 report names the `getattr` line and shows it arriving as an `INTERNALERROR`. The test added alongside that report, `test_warning_serialization_tweaked_module`, asserted `pytest.raises(ModuleNotFoundError)`: it characterised the defect rather than fixing it. It asserts the degradation now, and a second test covers the `AttributeError` shape, which is the one that report actually hit. Both resolutions degrade to the generic `Warning` this function already builds for a warning it cannot rebuild, and the fallback text carries the reason. A guard widened around an import is how a genuinely broken package turns into a warning nobody can explain. The category resolution below it had no guard and no test either, and `category` is what pytest filters and reports on. It degrades to the message's own class rather than to `None`, because pytest renders a warning through `warnings.formatwarning`, which reads `category.__name__`. Closes pytest-dev#404. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Resolving a warning's class on the controller is an
importlib.import_moduleand agetattr:Both run in the controller's receiver thread, and anything they raise ends the session: the node goes down mid-test and the run fails in the scheduler with
KeyError: <WorkerController gwN>— a different subsystem, naming nothing that leads back to the import.This is #404. Open since 2019, and its 2022 report names the
getattrline and shows it arriving as anINTERNALERROR.test_warning_serialization_tweaked_modulewas added alongside that report and assertedpytest.raises(ModuleNotFoundError): it characterised the defect rather than fixing it. It asserts the degradation now, and a second test covers theAttributeErrorshape, which is the one that report actually hit.Both resolutions degrade to the generic
Warningthis function already builds for a warning it cannot rebuild, and the fallback text carries the reason (class not resolved: ModuleNotFoundError: ...). A guard widened around an import is how a genuinely broken package turns into a warning nobody can explain.The category resolution below it had no guard and no test either, and
categoryis what pytest filters and reports on. It degrades to the message's own class rather than toNone, because pytest renders a warning throughwarnings.formatwarning, which readscategory.__name__— soNonewould end the run just as surely as the unguardedgetattrit replaces.Field evidence. In uibcdf/molsysviewer#76, a cold
import molsysmtraising inside the receiver thread discarded roughly 950 tests per occurrence, on about half of all-n 12runs. It took three attempts to attribute, because the error names the scheduler and the cause is an import two steps away. A warning failing to deserialize should not be able to do that.Tests
One each for an unimportable module, a class missing from its module, and an unresolvable category, plus the rewrite of the GH#404 test. Mutation-verified: removing the message-class guard fails 3 tests, the category guard 2.
Closes #404.
Split out of #1372, which keeps the separate question of transferring a warning's state — the two touch the same function but neither needs the other, and this half has the user-visible failure.
The two red
py311-pytestmainchecks are #1386 (--dist=loadgroupsilently losing its grouping on pytest main): unrelated to this change, and red on every open PR in the repo since pytest-dev/pytest#14758 merged on 2026-09-06.