diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 94babe39..05e24bce 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,10 +12,10 @@ on: jobs: julia: - name: Test (${{ matrix.os }}, julia ${{ matrix.jlversion }}) + name: Test Julia (${{ matrix.jlversion }} on ${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: - fail-fast: true + fail-fast: false matrix: arch: [x64] # x86 unsupported by MicroMamba os: [ubuntu-latest, windows-latest, macos-latest] @@ -50,13 +50,13 @@ jobs: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} python: - name: Test (${{ matrix.os }}, python ${{ matrix.pyversion }}) + name: Test Python (${{ matrix.pyversion }} on ${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: - fail-fast: true + fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] - pyversion: [">=3.8", "3.8"] + pyversion: ["3", "3.13.2", "3.13.1", "3.13.0", "3.12", "3.8"] steps: - uses: actions/checkout@v4 @@ -93,8 +93,15 @@ jobs: uv run pytest -s --nbval --cov=pysrc ./pytest/ env: PYTHON_JULIACALL_THREADS: '2' + PYTHON_JULIACALL_HANDLE_SIGNALS: 'yes' - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + - name: Setup tmate session on failure + uses: mxschmitt/action-tmate@v3 + if: ${{ failure() }} + with: + limit-access-to-actor: true diff --git a/pytest/test_all.py b/pytest/test_all.py index 9cdc8ce4..e6e8f861 100644 --- a/pytest/test_all.py +++ b/pytest/test_all.py @@ -94,8 +94,8 @@ def test_issue_433(): def test_julia_gc(): from juliacall import Main as jl - if jl.seval('v"1.11.0-" <= VERSION < v"1.11.3"'): - # Seems to be a Julia bug - hopefully fixed in 1.11.3 + if jl.seval('v"1.11.0-" <= VERSION < v"1.11.6"'): + # Seems to be a Julia bug - hopefully fixed in 1.11.6 pytest.skip("Test not yet supported on Julia 1.11+") # We make a bunch of python objects with no reference to them, diff --git a/src/JlWrap/C.jl b/src/JlWrap/C.jl index 7b181881..03d7ae2e 100644 --- a/src/JlWrap/C.jl +++ b/src/JlWrap/C.jl @@ -64,6 +64,7 @@ function _pyjl_callmethod(o::C.PyPtr, args::C.PyPtr) end const PYJLBUFCACHE = Dict{Ptr{Cvoid},Any}() +const PYJLBUFCACHE_DEBUG = [] @kwdef struct PyBufferInfo{N} # data @@ -177,7 +178,9 @@ function _pyjl_get_buffer_impl( # internal cptr = Base.pointer_from_objref(c) + @assert !haskey(PYJLBUFCACHE, cptr) PYJLBUFCACHE[cptr] = c + push!(PYJLBUFCACHE_DEBUG, c) b.internal[] = cptr # obj diff --git a/src/Utils/Utils.jl b/src/Utils/Utils.jl index 6e7b3f4d..bff10d6b 100644 --- a/src/Utils/Utils.jl +++ b/src/Utils/Utils.jl @@ -21,24 +21,6 @@ function explode_union(T) end end -""" - pointer_from_obj(x) - -Returns `(p, c)` where `Base.pointer_from_objref(p) === x`. - -The pointer remains valid provided the object `c` is not garbage collected. -""" -function pointer_from_obj(o::T) where {T} - if T.mutable - c = o - p = Base.pointer_from_objref(o) - else - c = Ref{Any}(o) - p = unsafe_load(Ptr{Ptr{Cvoid}}(Base.pointer_from_objref(c))) - end - p, c -end - """ ExtraNewline(x)