cpython icon indicating copy to clipboard operation
cpython copied to clipboard

gh-142349: Implement PEP 810

Open pablogsal opened this issue 3 weeks ago • 15 comments

  • Issue: gh-142349

⚠️ Dear reviewers, to avoid collapsing the GitHub API with a lot of comments, please open PRs against the base branch with any suggestions or fixes if you are sure are not controversial ⚠️


📚 Documentation preview 📚: https://cpython-previews--142351.org.readthedocs.build/

pablogsal avatar Dec 06 '25 15:12 pablogsal

CC @DinoV @Yhg1s

pablogsal avatar Dec 06 '25 15:12 pablogsal

@DinoV I have rebased and added a bunch of tests and a lot of stuff that was missing from the final version of the PEP.

pablogsal avatar Dec 06 '25 15:12 pablogsal

⚠️ Dear reviewers, to avoid collapsing the GitHub API with a lot of comments, please open PRs against the base branch with any suggestions or fixes if you are sure are not controversial ⚠️

pablogsal avatar Dec 06 '25 15:12 pablogsal

@pablogsal PTAL https://github.com/LazyImportsCabal/cpython/pull/25

picnixz avatar Dec 06 '25 18:12 picnixz

I'll be doing small reviews because I'm not on my dev session and it takes too long for creating a PR :') I promise I won't be too nitpicky!

picnixz avatar Dec 06 '25 18:12 picnixz

@DinoV @colesbury I haven't paid attention to FT when I updated the draft implementation so please take a special look at that

pablogsal avatar Dec 06 '25 19:12 pablogsal

@DinoV @colesbury I haven't paid attention to FT when I updated the draft implementation so please take a special look at that

In particular ./python -m test test_import.test_lazy_imports -v shows some tsan problems.

I think I got them in 470b9e4 but not sure if that's the best way to fix this.

pablogsal avatar Dec 06 '25 19:12 pablogsal

@StanFromIreland assertIn/assertNotIn is addressed in https://github.com/LazyImportsCabal/cpython/pull/28

picnixz avatar Dec 07 '25 09:12 picnixz

Great minds think alike;-) I had opened https://github.com/LazyImportsCabal/cpython/pull/27 for it.

StanFromIreland avatar Dec 07 '25 10:12 StanFromIreland

There was also an hasattr check thatq we could change and I also changed import order to make them alphabetically sorted. Do you mind merging my PR in yours?

picnixz avatar Dec 07 '25 10:12 picnixz

Do you mind merging my PR in yours?

Done :-)

StanFromIreland avatar Dec 07 '25 10:12 StanFromIreland

@pablogsal

  • PEP-7 nits in import.c: https://github.com/LazyImportsCabal/cpython/pull/29
  • Docs fixes: https://github.com/LazyImportsCabal/cpython/pull/32
  • PR fixing UAFs/error paths in import.c: https://github.com/LazyImportsCabal/cpython/pull/30
  • PR for fixing lazy_import.__new__ and UBs: https://github.com/LazyImportsCabal/cpython/pull/31
  • PR fox fixing UAFs/error paths in Python/*.c: https://github.com/LazyImportsCabal/cpython/pull/33
  • PR for fixing the compilation issues in the CI: https://github.com/LazyImportsCabal/cpython/pull/34

There are other places where PEP-7 is not applied but I won't bother changing those places if I'm not changing the effective code as well. Ideally, I should add tests for checking that my UAFs fixes are correct but we can do it once they're reviewed and merged.

picnixz avatar Dec 07 '25 11:12 picnixz

  • Docs failures: related to a missing label (profiling)
  • Generated files: we didn't update stable_abi.dat (forgot about it). Run make check-limited or something like that to know what to do

picnixz avatar Dec 08 '25 00:12 picnixz

Doctest failures: we are missing is_lazy=0 in the doctest output, in library/ast.rst.

picnixz avatar Dec 08 '25 00:12 picnixz

All commit authors signed the Contributor License Agreement.

CLA signed

python-cla-bot[bot] avatar Dec 15 '25 11:12 python-cla-bot[bot]