479.importlib bug workaround #498
Merged
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.
This is an attempt to further mitigate #479. It probably cannot be said that this fixes that issue because any other
__del__, weakref callback, or signal handler could still introduce an import at a bad time.Still, maybe it is worth having until CPython does something about the underlying issue. The change does mean ResourceWarning reporting by pytest will be lost. I don't think that's a big deal because I don't think anyone is paying attention to that information right now anyway (if we wanted GridSync to be ResourceWarning-free then I expect we would add a CI job that configures a warnings filter like "error::ResourceWarning" and this should also avoid the CPython bug).
Also included here is a change to PYTHONDONTWRITEBYTECODE so that it is set consistently for all platforms when using tox instead of only being set for Windows. It was set for Windows because it managed to mitigate the CPython bug but it did so in a more fragile way than this warnings reconfiguration (I think) but it is a pretty reasonable thing to set anyway since pyc files mostly add complexity.