JuliaPy / PyCall.jl

Package to call Python functions from the Julia language
MIT License
1.47k stars 187 forks source link

fix BoundsError of args[1] when args is empty #1014

Closed szcf-weiya closed 1 year ago

szcf-weiya commented 1 year ago

if args on L101 is empty, then args[1] in isexpr() would throw BoundsError: attempt to access 0-element Vector{Any} at index [1]

julia> ex = :(f()::Float64)
:(f()::Float64)

julia> args = ex.args[1].args[2:end]
Any[]

julia> args[1]
ERROR: BoundsError: attempt to access 0-element Vector{Any} at index [1]
Stacktrace:
 [1] getindex(A::Vector{Any}, i1::Int64)
   @ Base ./array.jl:924
 [2] top-level scope
   @ REPL[118]:1
codecov-commenter commented 1 year ago

Codecov Report

Base: 68.35% // Head: 68.33% // Decreases project coverage by -0.01% :warning:

Coverage data is based on head (00d3582) compared to base (9f22684). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1014 +/- ## ========================================== - Coverage 68.35% 68.33% -0.02% ========================================== Files 20 20 Lines 2038 2040 +2 ========================================== + Hits 1393 1394 +1 - Misses 645 646 +1 ``` | Flag | Coverage Δ | | |---|---|---| | unittests | `68.33% <100.00%> (-0.02%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://codecov.io/gh/JuliaPy/PyCall.jl/pull/1014?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [src/pyfncall.jl](https://codecov.io/gh/JuliaPy/PyCall.jl/pull/1014/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL3B5Zm5jYWxsLmps) | `97.43% <100.00%> (+0.06%)` | :arrow_up: | | [src/pyinit.jl](https://codecov.io/gh/JuliaPy/PyCall.jl/pull/1014/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL3B5aW5pdC5qbA==) | `82.00% <0.00%> (-1.00%)` | :arrow_down: | | [src/pyclass.jl](https://codecov.io/gh/JuliaPy/PyCall.jl/pull/1014/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL3B5Y2xhc3Muamw=) | `96.77% <0.00%> (+0.05%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.