python-trio / trio

Trio – a friendly Python library for async concurrency and I/O
https://trio.readthedocs.io
Other
5.98k stars 325 forks source link

Fixes for 3.13 #3005

Closed A5rocks closed 2 weeks ago

A5rocks commented 1 month ago

Fixes https://github.com/python-trio/trio/issues/3004, also refs https://github.com/python-trio/trio/issues/2885

@njsmith could you check my naive locals() -> sys._getframe().f_locals replacement? Unfortunately 3.13 makes locals() mutations not mutate actual local variables, as part of PEP 667. I'm especially not sure about the replacement in _run.py where locals() used to clear something (not sure what).

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.63%. Comparing base (3350c11) to head (f62e81e). Report is 5 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #3005 +/- ## ======================================== Coverage 99.63% 99.63% ======================================== Files 120 120 Lines 17783 17963 +180 Branches 3197 3243 +46 ======================================== + Hits 17718 17898 +180 Misses 46 46 Partials 19 19 ``` | [Files](https://app.codecov.io/gh/python-trio/trio/pull/3005?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-trio) | Coverage Δ | | |---|---|---| | [src/trio/\_core/\_ki.py](https://app.codecov.io/gh/python-trio/trio/pull/3005?src=pr&el=tree&filepath=src%2Ftrio%2F_core%2F_ki.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-trio#diff-c3JjL3RyaW8vX2NvcmUvX2tpLnB5) | `100.00% <100.00%> (ø)` | | | [src/trio/\_core/\_run.py](https://app.codecov.io/gh/python-trio/trio/pull/3005?src=pr&el=tree&filepath=src%2Ftrio%2F_core%2F_run.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-trio#diff-c3JjL3RyaW8vX2NvcmUvX3J1bi5weQ==) | `99.38% <100.00%> (+0.04%)` | :arrow_up: | | [src/trio/\_path.py](https://app.codecov.io/gh/python-trio/trio/pull/3005?src=pr&el=tree&filepath=src%2Ftrio%2F_path.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-trio#diff-c3JjL3RyaW8vX3BhdGgucHk=) | `100.00% <100.00%> (ø)` | | | [src/trio/\_tests/test\_exports.py](https://app.codecov.io/gh/python-trio/trio/pull/3005?src=pr&el=tree&filepath=src%2Ftrio%2F_tests%2Ftest_exports.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-trio#diff-c3JjL3RyaW8vX3Rlc3RzL3Rlc3RfZXhwb3J0cy5weQ==) | `99.61% <100.00%> (+<0.01%)` | :arrow_up: | | [src/trio/\_tests/test\_path.py](https://app.codecov.io/gh/python-trio/trio/pull/3005?src=pr&el=tree&filepath=src%2Ftrio%2F_tests%2Ftest_path.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-trio#diff-c3JjL3RyaW8vX3Rlc3RzL3Rlc3RfcGF0aC5weQ==) | `100.00% <100.00%> (ø)` | | | [src/trio/\_tools/gen\_exports.py](https://app.codecov.io/gh/python-trio/trio/pull/3005?src=pr&el=tree&filepath=src%2Ftrio%2F_tools%2Fgen_exports.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-trio#diff-c3JjL3RyaW8vX3Rvb2xzL2dlbl9leHBvcnRzLnB5) | `99.15% <100.00%> (ø)` | | | [src/trio/socket.py](https://app.codecov.io/gh/python-trio/trio/pull/3005?src=pr&el=tree&filepath=src%2Ftrio%2Fsocket.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-trio#diff-c3JjL3RyaW8vc29ja2V0LnB5) | `100.00% <ø> (ø)` | | ... and [6 files with indirect coverage changes](https://app.codecov.io/gh/python-trio/trio/pull/3005/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=python-trio)
richardsheridan commented 1 month ago

Seems like with these changes CancelScope.__exit__ doesn't need to inline the KI protection decorator anymore, so I pushed a commit on that.

A5rocks commented 3 weeks ago

I think this is ready for review/merge. While this applied as a patch doesn't seem to work, I can't seem to reproduce that and I'm sure it's just some other PR that changed things just enough for this subtle locals stuff to work (which can be located probably just using a git bisect?).

jakkdl commented 2 weeks ago

I think you can get 3.13 to pass in CI if you explicitly install cffi==1.17.0rc1 as a dependency: https://github.com/python-cffi/cffi/releases/tag/v1.17.0rc1 Since it's a release candidate pip doesn't automatically target it.

I wrote a PR to get trio-websocket to support trio>0.25 https://github.com/python-trio/trio-websocket/pull/188, so once merged that may fully resolve the issues encountered by the distro maintainers.

A5rocks commented 2 weeks ago

Alright, this is now running the whole test suite (rather than the part that doesn't require the test requirements).