gh-142349: Implement PEP 810
- 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/
CC @DinoV @Yhg1s
@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.
⚠️ 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 PTAL https://github.com/LazyImportsCabal/cpython/pull/25
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!
@DinoV @colesbury I haven't paid attention to FT when I updated the draft implementation so please take a special look at that
@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.
@StanFromIreland assertIn/assertNotIn is addressed in https://github.com/LazyImportsCabal/cpython/pull/28
Great minds think alike;-) I had opened https://github.com/LazyImportsCabal/cpython/pull/27 for it.
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?
Do you mind merging my PR in yours?
Done :-)
@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.
- Docs failures: related to a missing label (profiling)
- Generated files: we didn't update stable_abi.dat (forgot about it). Run
make check-limitedor something like that to know what to do
Doctest failures: we are missing is_lazy=0 in the doctest output, in library/ast.rst.