FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-150167: Force eager import of `_bz2` in `bz2.py` to fix supported format detection by DavidCEllis · Pull Request #154771 · python/cpython · GitHub

Repository navigation

gh-150167: Force eager import of _bz2 in bz2.py to fix supported format detection - #154771

Closed
DavidCEllis wants to merge 10 commits into
python:mainfrom
DavidCEllis:fix-lazy-archive-detection-minimal
Closed

DavidCEllis wants to merge 10 commits into
python:mainfrom
DavidCEllis:fix-lazy-archive-detection-minimal

Conversation

DavidCEllis commented Jul 27, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

This adds import _bz2; _bz2 to bz2.py which has the effect of making the import eager even under the 'all' lazy imports mode.

Fixes the issue where bz2 would always be reported as supported by shutil under lazy_imports=all even if it was unavailable. This should also fix this same logic where it's reused in other places (such as test_support).

I think it may make sense to add a SUPPORTED_MODULES attribute to compression that lists which modules are available by checking the internal modules directly, but that can be done on top of this.


The 'import' change that added all of the import codeowners as reviewers:

In order to test that a fresh shutil would correctly identify 'bz2' as unavailable if _bz2 is blocked I needed to add an argument to test.support.import_helpers.import_fresh_module to allow bz2 to be cleared without requiring it successfully re-import. This is the new optional cleared argument.

This new argument is documented, along with the previously undocumented 'usefrozen' argument and the signature in the documentation now correctly identifies the 'deprecated' argument as keyword-only.

read-the-docs-community Bot commented Jul 27, 2026 •
edited
Loading

Copy link
Copy Markdown

brettcannon removed their request for review August 6, 2026 19:30

Copy link
Copy Markdown
Contributor Author

This PR needs to be updated to test the compression modules directly rather than through shutil due to the changes in shutil that make it import the internal modules directly now.

DavidCEllis marked this pull request as draft September 8, 2026 12:01
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL