Skip to content

fix: minor robustness fixes from code review - #1121

Merged
gaborbernat merged 3 commits into
pypa:mainfrom
henryiii:fix/minor-robustness
Jul 2, 2026
Merged

gaborbernat merged 3 commits into
pypa:mainfrom
henryiii:fix/minor-robustness

Conversation

@henryiii

@henryiii henryiii commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

I need to edit this a bit, leaving it in draft until I do.

🤖 AI text below 🤖

A batch of minor robustness fixes found during code review.

Part of the code review in #1116.

  1. env._get_minimum_pip_version_str: parse the macOS release with split(".", 1)[0] instead of slicing at find("."). The old code truncated the last digit of a dot-less release (e.g. "15" became "1") and raised ValueError on an empty release. An empty release now falls back to the generic minimum.
  2. _builder._parse_build_system_table: return a fresh copy of the default build-system table (including a fresh requires list) so a caller mutating the result cannot corrupt the shared module-level default for every later builder in the process.
  3. env.DefaultIsolatedEnv.__enter__: assign self._path before calling os.path.realpath, so a failure there no longer masks the original exception with an AttributeError from __exit__ and no longer leaks the mkdtemp directory.
  4. _builder.metadata_path: raise BuildException (not a bare ValueError) for an invalid wheel, so the CLI renders it nicely like every other failure in this package.
  5. _builder._read_pyproject_toml: remove stray trailing spaces from two error messages.

Regression tests were added for items 1-4 (test-first, confirmed failing before the fixes).

@henryiii
henryiii force-pushed the fix/minor-robustness branch from ac1a5af to cce9133 Compare July 1, 2026 20:25
Comment thread src/build/env.py Resolved
@henryiii
henryiii force-pushed the fix/minor-robustness branch from e6c1d1a to 84a6947 Compare July 2, 2026 22:22
henryiii added 3 commits July 2, 2026 18:36
- env: parse macOS release with split() so a dot-less release (e.g. '15')
  is not truncated and an empty release no longer raises ValueError
- _builder: return a fresh copy of the default build-system table so a
  caller mutating requires cannot corrupt later builders in the process
- env: set self._path before os.path.realpath so a failure there does not
  mask the original exception with AttributeError and leak the temp dir
- _builder: raise BuildException (not ValueError) for an invalid wheel so
  the CLI renders it nicely
- _builder: drop stray trailing spaces in two error messages

Assisted-by: ClaudeCode:claude-opus-4.8
Assisted-by: ClaudeCode:claude-opus-4.8
The with-statement body in test_isolated_env_enter_failure_before_path_set
never ran (the mocked __enter__ raises first), failing the 100% coverage
gate on test files.

Assisted-by: ClaudeCode:claude-opus-4.8
@henryiii
henryiii force-pushed the fix/minor-robustness branch from 84a6947 to 9d01415 Compare July 2, 2026 22:38
@henryiii
henryiii marked this pull request as ready for review July 2, 2026 22:43
@henryiii
henryiii requested a review from layday as a code owner July 2, 2026 22:43
@gaborbernat
gaborbernat merged commit 260ae22 into pypa:main Jul 2, 2026
59 checks passed
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.

3 participants