From cc9a07315af333cfd3989721f6175c0a552cb947 Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Sat, 3 May 2025 23:24:26 +0900 Subject: [PATCH 1/4] Fix step behavior for beginless ranges in Ruby 3.4+ See https://github.com/ruby/ruby/pull/7444 --- spec/pycall/pyobject_wrapper_spec.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/pycall/pyobject_wrapper_spec.rb b/spec/pycall/pyobject_wrapper_spec.rb index 5b37c70c..2afb3e56 100644 --- a/spec/pycall/pyobject_wrapper_spec.rb +++ b/spec/pycall/pyobject_wrapper_spec.rb @@ -161,7 +161,10 @@ module PyCall list = PyCall::List.new([*1..10]) expect(list[(1..-1).step(2)]).to eq(PyCall::List.new([2, 4, 6, 8, 10])) expect(list[(1..-2).step(2)]).to eq(PyCall::List.new([2, 4, 6, 8])) - expect(list[(nil..nil).step(-1)]).to eq(PyCall::List.new([*1..10].reverse)) + # In Ruby 3.4+, step for non-numeric beginless ranges raises ArgumentError + if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.4.0') + expect(list[(nil..nil).step(-1)]).to eq(PyCall::List.new([*1..10].reverse)) + end expect(list[(-1..0).step(-1)]).to eq(PyCall::List.new([*1..10].reverse)) expect(list[(-1...0).step(-1)]).to eq(PyCall::List.new([*2..10].reverse)) expect(list[(-2..2).step(-2)]).to eq(PyCall::List.new([9, 7, 5, 3])) From 72a55c8f7ce9a24253f79d3713738d92493b404c Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Sat, 3 May 2025 23:36:15 +0900 Subject: [PATCH 2/4] CI: Use ubuntu-22.04 for GitHub Actions --- .github/workflows/ci.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f519832..2edbc709 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: matrix: os: - ubuntu-latest - - ubuntu-20.04 + - ubuntu-22.04 - macos-latest ruby: - "3.4" @@ -39,27 +39,27 @@ jobs: - "" include: # Python 3.11 with the latest Ruby - - { os: ubuntu-20.04 , ruby: 3.3 , python: "3.11" , python_architecture: x64 , venv: "" } + - { os: ubuntu-22.04 , ruby: 3.3 , python: "3.11" , python_architecture: x64 , venv: "" } # Old ruby and the latest Python 3 - - { os: ubuntu-20.04 , ruby: 2.6 , python: "3.x" , python_architecture: x64 , venv: "" } - - { os: ubuntu-20.04 , ruby: 2.5 , python: "3.x" , python_architecture: x64 , venv: "" } - - { os: ubuntu-20.04 , ruby: 2.4 , python: "3.x" , python_architecture: x64 , venv: "" } + - { os: ubuntu-22.04 , ruby: 2.6 , python: "3.x" , python_architecture: x64 , venv: "" } + - { os: ubuntu-22.04 , ruby: 2.5 , python: "3.x" , python_architecture: x64 , venv: "" } + - { os: ubuntu-22.04 , ruby: 2.4 , python: "3.x" , python_architecture: x64 , venv: "" } # Ruby 2.7 with Each Python 3.x - - { os: ubuntu-20.04 , ruby: 2.7 , python: "3.12" , python_architecture: x64 , venv: "" } - - { os: ubuntu-20.04 , ruby: 2.7 , python: "3.11" , python_architecture: x64 , venv: "" } - - { os: ubuntu-20.04 , ruby: 2.7 , python: "3.10" , python_architecture: x64 , venv: "" } - - { os: ubuntu-20.04 , ruby: 2.7 , python: "3.9" , python_architecture: x64 , venv: "" } - - { os: ubuntu-20.04 , ruby: 2.7 , python: "3.8" , python_architecture: x64 , venv: "" } - - { os: ubuntu-20.04 , ruby: 2.7 , python: "3.7" , python_architecture: x64 , venv: "" } - - { os: ubuntu-20.04 , ruby: 2.7 , python: "3.6" , python_architecture: x64 , venv: "" } + - { os: ubuntu-22.04 , ruby: 2.7 , python: "3.12" , python_architecture: x64 , venv: "" } + - { os: ubuntu-22.04 , ruby: 2.7 , python: "3.11" , python_architecture: x64 , venv: "" } + - { os: ubuntu-22.04 , ruby: 2.7 , python: "3.10" , python_architecture: x64 , venv: "" } + - { os: ubuntu-22.04 , ruby: 2.7 , python: "3.9" , python_architecture: x64 , venv: "" } + - { os: ubuntu-22.04 , ruby: 2.7 , python: "3.8" , python_architecture: x64 , venv: "" } + - { os: ubuntu-22.04 , ruby: 2.7 , python: "3.7" , python_architecture: x64 , venv: "" } + - { os: ubuntu-22.04 , ruby: 2.7 , python: "3.6" , python_architecture: x64 , venv: "" } # Ruby-debug with the latest Python 3 - - { os: ubuntu-20.04 , ruby: debug , python: "3.x" , python_architecture: x64 , venv: "" } + - { os: ubuntu-22.04 , ruby: debug , python: "3.x" , python_architecture: x64 , venv: "" } # The latest stable Ruby with the latest Python 3 with venv - - { os: ubuntu-20.04 , ruby: "3.3" , python: "3.x" , python_architecture: x64 , venv: "venv:" } + - { os: ubuntu-22.04 , ruby: "3.3" , python: "3.x" , python_architecture: x64 , venv: "venv:" } # macOS with venv - { os: macos-latest , ruby: "3.3" , python: "3.x" , python_architecture: x64 , venv: "venv:" } @@ -110,7 +110,7 @@ jobs: fail-fast: false matrix: os: - - ubuntu-20.04 + - ubuntu-22.04 #- macos-latest ruby: - "3.1" From 04b1689fe99784ce64d1bdfa5f6a4161d4ba1da6 Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Sat, 3 May 2025 23:43:34 +0900 Subject: [PATCH 3/4] CI: Remove Python 3.6 --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2edbc709..2e6dafe6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,7 +53,6 @@ jobs: - { os: ubuntu-22.04 , ruby: 2.7 , python: "3.9" , python_architecture: x64 , venv: "" } - { os: ubuntu-22.04 , ruby: 2.7 , python: "3.8" , python_architecture: x64 , venv: "" } - { os: ubuntu-22.04 , ruby: 2.7 , python: "3.7" , python_architecture: x64 , venv: "" } - - { os: ubuntu-22.04 , ruby: 2.7 , python: "3.6" , python_architecture: x64 , venv: "" } # Ruby-debug with the latest Python 3 - { os: ubuntu-22.04 , ruby: debug , python: "3.x" , python_architecture: x64 , venv: "" } From 7916cb1bcb65883d2adf93560e433ef3c5f04eb8 Mon Sep 17 00:00:00 2001 From: kojix2 <2xijok@gmail.com> Date: Sun, 4 May 2025 07:12:09 +0900 Subject: [PATCH 4/4] Revert "Fix step behavior for beginless ranges in Ruby 3.4+" This reverts commit cc9a07315af333cfd3989721f6175c0a552cb947. --- spec/pycall/pyobject_wrapper_spec.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/spec/pycall/pyobject_wrapper_spec.rb b/spec/pycall/pyobject_wrapper_spec.rb index 2afb3e56..5b37c70c 100644 --- a/spec/pycall/pyobject_wrapper_spec.rb +++ b/spec/pycall/pyobject_wrapper_spec.rb @@ -161,10 +161,7 @@ module PyCall list = PyCall::List.new([*1..10]) expect(list[(1..-1).step(2)]).to eq(PyCall::List.new([2, 4, 6, 8, 10])) expect(list[(1..-2).step(2)]).to eq(PyCall::List.new([2, 4, 6, 8])) - # In Ruby 3.4+, step for non-numeric beginless ranges raises ArgumentError - if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.4.0') - expect(list[(nil..nil).step(-1)]).to eq(PyCall::List.new([*1..10].reverse)) - end + expect(list[(nil..nil).step(-1)]).to eq(PyCall::List.new([*1..10].reverse)) expect(list[(-1..0).step(-1)]).to eq(PyCall::List.new([*1..10].reverse)) expect(list[(-1...0).step(-1)]).to eq(PyCall::List.new([*2..10].reverse)) expect(list[(-2..2).step(-2)]).to eq(PyCall::List.new([9, 7, 5, 3]))