From e79b1398b002b85f0426864feaa4c01036075a2b Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Fri, 17 Feb 2023 23:33:04 +0900 Subject: [PATCH 1/4] trying to go with CPython 3.11 --- .github/workflows/ci.yaml | 8 ++++---- .github/workflows/cron-ci.yaml | 2 +- DEVELOPMENT.md | 2 +- README.md | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a06efd52cf..7bc399cac6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -250,7 +250,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - uses: actions/setup-python@v2 with: - python-version: "3.10" + python-version: "3.11" - name: Set up the Windows environment shell: bash run: | @@ -266,7 +266,7 @@ jobs: run: cargo build --release --verbose --features=threading ${{ env.CARGO_ARGS }} - uses: actions/setup-python@v2 with: - python-version: "3.10" + python-version: "3.11" - name: run snippets run: python -m pip install -r requirements.txt && pytest -v working-directory: ./extra_tests @@ -349,7 +349,7 @@ jobs: run: cargo clippy --manifest-path=wasm/lib/Cargo.toml -- -Dwarnings - uses: actions/setup-python@v2 with: - python-version: "3.10" + python-version: "3.11" - name: install flake8 run: python -m pip install flake8 - name: run lint @@ -411,7 +411,7 @@ jobs: tar -xzf geckodriver-v0.30.0-linux64.tar.gz -C geckodriver - uses: actions/setup-python@v2 with: - python-version: "3.10" + python-version: "3.11" - run: python -m pip install -r requirements.txt working-directory: ./wasm/tests - uses: actions/setup-node@v1 diff --git a/.github/workflows/cron-ci.yaml b/.github/workflows/cron-ci.yaml index 6321a80604..7a16dd92f8 100644 --- a/.github/workflows/cron-ci.yaml +++ b/.github/workflows/cron-ci.yaml @@ -29,7 +29,7 @@ jobs: RUSTC_WRAPPER: './scripts/codecoverage-rustc-wrapper.sh' - uses: actions/setup-python@v2 with: - python-version: "3.10" + python-version: "3.11" - run: python -m pip install pytest working-directory: ./extra_tests - name: run snippets diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 35751ba0fc..2b32ad7b13 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -25,7 +25,7 @@ RustPython requires the following: stable version: `rustup update stable` - If you do not have Rust installed, use [rustup](https://rustup.rs/) to do so. -- CPython version 3.10 or higher +- CPython version 3.11 or higher - CPython can be installed by your operating system's package manager, from the [Python website](https://www.python.org/downloads/), or using a third-party distribution, such as diff --git a/README.md b/README.md index 50b3c039e1..91b24b229f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # [RustPython](https://rustpython.github.io/) -A Python-3 (CPython >= 3.10.0) Interpreter written in Rust :snake: :scream: +A Python-3 (CPython >= 3.11.0) Interpreter written in Rust :snake: :scream: :metal:. [![Build Status](https://github.com/RustPython/RustPython/workflows/CI/badge.svg)](https://github.com/RustPython/RustPython/actions?query=workflow%3ACI) From d22446d1dd5cf521f799231557f021b7575d2305 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Sat, 18 Feb 2023 07:08:24 +0900 Subject: [PATCH 2/4] imp.py -> stdlib_imp.py --- extra_tests/snippets/{imp.py => stdlib_imp.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename extra_tests/snippets/{imp.py => stdlib_imp.py} (100%) diff --git a/extra_tests/snippets/imp.py b/extra_tests/snippets/stdlib_imp.py similarity index 100% rename from extra_tests/snippets/imp.py rename to extra_tests/snippets/stdlib_imp.py From 8c38a8381cf016c8979aef82a3d7a42c59e0dd30 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Sat, 18 Feb 2023 07:08:36 +0900 Subject: [PATCH 3/4] os is frozen in 3.11 --- extra_tests/snippets/stdlib_imp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra_tests/snippets/stdlib_imp.py b/extra_tests/snippets/stdlib_imp.py index c7e4a90258..bd28e95f3d 100644 --- a/extra_tests/snippets/stdlib_imp.py +++ b/extra_tests/snippets/stdlib_imp.py @@ -6,7 +6,7 @@ assert _imp.is_builtin("not existing module") == False assert _imp.is_frozen("__hello__") == True -assert _imp.is_frozen("os") == False +assert _imp.is_frozen("math") == False class FakeSpec: def __init__(self, name): From 75f3f3c8c4857aa1943fda6aa1a0468cab3ebc6a Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Mon, 20 Feb 2023 02:06:21 +0900 Subject: [PATCH 4/4] Fix syntax_async.py for 3.11 --- extra_tests/snippets/syntax_async.py | 77 +++++++++++++++------------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/extra_tests/snippets/syntax_async.py b/extra_tests/snippets/syntax_async.py index 0b0d3e0484..6486feb393 100644 --- a/extra_tests/snippets/syntax_async.py +++ b/extra_tests/snippets/syntax_async.py @@ -1,6 +1,8 @@ +import sys import asyncio import unittest + class ContextManager: async def __aenter__(self): print("Entrada") @@ -41,15 +43,18 @@ async def a(s, m): async for i in AIterWrap(range(0, 2)): print(i) ls.append(m) - await asyncio.sleep(1) + await asyncio.sleep(0.1) + + +async def main(): + tasks = [ + asyncio.create_task(c) + for c in [a(0, "hello1"), a(0.1, "hello2"), a(0.2, "hello3"), a(0.3, "hello4")] + ] + await asyncio.wait(tasks) -loop = asyncio.get_event_loop() -loop.run_until_complete( - asyncio.wait( - [a(0, "hello1"), a(0.75, "hello2"), a(1.5, "hello3"), a(2.25, "hello4")] - ) -) +asyncio.run(main(), debug=True) assert ls == [ @@ -72,41 +77,43 @@ async def a(s, m): ] -class TestAsyncWith(unittest.TestCase): - def testAenterAttributeError1(self): - class LacksAenter(object): - async def __aexit__(self, *exc): - pass +if sys.version_info < (3, 11, 0): - async def foo(): - async with LacksAenter(): - pass - - with self.assertRaisesRegex(AttributeError, '__aenter__'): - foo().send(None) + class TestAsyncWith(unittest.TestCase): + def testAenterAttributeError1(self): + class LacksAenter(object): + async def __aexit__(self, *exc): + pass - def testAenterAttributeError2(self): - class LacksAenterAndAexit(object): - pass + async def foo(): + async with LacksAenter(): + pass - async def foo(): - async with LacksAenterAndAexit(): + with self.assertRaisesRegex(AttributeError, "__aenter__"): + foo().send(None) + + def testAenterAttributeError2(self): + class LacksAenterAndAexit(object): pass - with self.assertRaisesRegex(AttributeError, '__aenter__'): - foo().send(None) + async def foo(): + async with LacksAenterAndAexit(): + pass - def testAexitAttributeError(self): - class LacksAexit(object): - async def __aenter__(self): - pass + with self.assertRaisesRegex(AttributeError, "__aenter__"): + foo().send(None) - async def foo(): - async with LacksAexit(): - pass - - with self.assertRaisesRegex(AttributeError, '__aexit__'): - foo().send(None) + def testAexitAttributeError(self): + class LacksAexit(object): + async def __aenter__(self): + pass + + async def foo(): + async with LacksAexit(): + pass + + with self.assertRaisesRegex(AttributeError, "__aexit__"): + foo().send(None) if __name__ == "__main__":