Skip to content

Conversation

AA-Turner
Copy link
Member

@AA-Turner AA-Turner commented Sep 4, 2025

  • KeyError is not raised for defaultdict, use an explicit test
  • Fix relative paths on different drives on Windows
  • Add a round-trip test

* KeyError is not raised for defaultdict
* Fix relative paths on different drives on Windows
* Add a round-trip test
@AA-Turner AA-Turner requested review from itamaro and FFY00 September 4, 2025 19:53
@AA-Turner AA-Turner added the needs backport to 3.14 bugs and security fixes label Sep 4, 2025
@AA-Turner AA-Turner changed the title gh-136264: Fix `--relative-paths for PEP 739's build-details.json gh-136264: Fix --relative-paths for PEP 739's build-details.json Sep 4, 2025
AA-Turner added a commit to AA-Turner/cpython that referenced this pull request Sep 4, 2025
Copy link
Contributor

@itamaro itamaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like CI is unhappy

@AA-Turner AA-Turner requested a review from itamaro September 8, 2025 00:07
@AA-Turner AA-Turner merged commit 057ee17 into python:main Sep 8, 2025
51 checks passed
@miss-islington-app
Copy link

Thanks @AA-Turner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 8, 2025
….json (pythonGH-138510)

* KeyError is not raised for defaultdict
* Fix relative paths on different drives on Windows
* Add a round-trip test
(cherry picked from commit 057ee17)

Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Itamar Oren <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Sep 8, 2025

GH-138638 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Sep 8, 2025
@AA-Turner AA-Turner deleted the pep739-relative-paths branch September 8, 2025 09:15
hugovk added a commit that referenced this pull request Sep 9, 2025
…s.json (GH-138510) (#138638)

* gh-136264: Fix ``--relative-paths`` for PEP 739's build-details.json (GH-138510)

* KeyError is not raised for defaultdict
* Fix relative paths on different drives on Windows
* Add a round-trip test
(cherry picked from commit 057ee17)

Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Itamar Oren <[email protected]>

* Update test_build_details.py

* Update Lib/test/test_build_details.py

---------

Co-authored-by: Adam Turner <[email protected]>
Co-authored-by: Itamar Oren <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
lkollar pushed a commit to lkollar/cpython that referenced this pull request Sep 9, 2025
….json (python#138510)

* KeyError is not raised for defaultdict
* Fix relative paths on different drives on Windows
* Add a round-trip test

Co-authored-by: Itamar Oren <[email protected]>
@DinoV
Copy link
Contributor

DinoV commented Sep 11, 2025

Hey @AA-Turner we may be a special snowflake here but the import importlib and then importlib.util.... usage has broken running this test internally for Cinder. It seems like this is usually imported by pyrun (and/or the new REPL) but there may be other ways for things to run w/o importing it. Do you think this should be a import importlib.util?

@AA-Turner
Copy link
Member Author

AA-Turner commented Sep 11, 2025

Hmm, does this pattern reproduce generally, or is it just specific to this test?

If the former, I'm inclined to think it might be a bug in Cinder.

Will return to consider this tonight (UK time).

A

facebook-github-bot pushed a commit to facebookincubator/cinderx that referenced this pull request Sep 11, 2025
Summary:
An upstream change uses importlib.util after only importing importlib: python/cpython#138510

In normal CPython this gets mported via runpy so it pretty much always available. In our dev environment we don't import it, so this just makes sure it gets imported for test purposes.

Reviewed By: yoney

Differential Revision: D82228954

fbshipit-source-id: 86e1cd776d2a3819ffff9c6069613d141ab88dd1
@DinoV
Copy link
Contributor

DinoV commented Sep 12, 2025

I'm not sure how to trigger it on stock CPython which is why I just started the discussion rather than opening an issue. But generally "import foo" followed by using a subpackage of foo without importing it is a bit of an anti-pattern - it's relying on someone else having imported the subpackage earlier.

In my (limited) experiments importlib.util was either being imported via pyrepl (normal startup path) or runpy (doing python -c "import importlib; print(dir(importlib))". I didn't dig past that and just made sure we have it imported.

There may be some other embedding scenarios but maybe not too many running the test suite!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants