Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyObject not automatically converted to Julia type in Debugger #415

Closed
cuihantao opened this issue Jul 3, 2020 · 1 comment · Fixed by #456
Closed

PyObject not automatically converted to Julia type in Debugger #415

cuihantao opened this issue Jul 3, 2020 · 1 comment · Fixed by #456

Comments

@cuihantao
Copy link

cuihantao commented Jul 3, 2020

Hi,

I'm looking to debug Julia code that uses NumPy through PyCall. It turns out that PyObjects are not automatically converted to Julia types when debugging with Debugger.

The same issue has been posted at JunoLab/Juno.jl#591.

To reproduce the issue, do the following in REPL

julia> using Debugger

julia> using PyCall

julia> function test()
       np = pyimport("numpy")
       a = np.zeros(3)
       b = Array(a)
       end
test (generic function with 1 method)

julia> @run test()
ERROR: MethodError: no method matching Array(::PyObject)
Closest candidates are:
  Array(::LinearAlgebra.SymTridiagonal) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/LinearAlgebra/src/tridiag.jl:111
  Array(::LinearAlgebra.Tridiagonal) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/LinearAlgebra/src/tridiag.jl:528
  Array(::LinearAlgebra.AbstractTriangular) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.4/LinearAlgebra/src/triangular.jl:162
  ...
Stacktrace:
 [1] test() at REPL[14]:4

julia> test()
3-element Array{Float64,1}:
 0.0
 0.0
 0.0
@cuihantao cuihantao changed the title PyObject not automatically converted to Julia Array in Debugger PyObject not automatically converted to Julia types in Debugger Jul 3, 2020
@cuihantao cuihantao changed the title PyObject not automatically converted to Julia types in Debugger PyObject not automatically converted to Julia type in Debugger Jul 3, 2020
@timholy
Copy link
Member

timholy commented Dec 16, 2020

Reduced:

julia> using JuliaInterpreter, PyCall

julia> np = pyimport("numpy");

julia> @interpret pytype_query(np.zeros)
ERROR: TypeError: in cglobal, expected Symbol, got a value of type JuliaInterpreter.SSAValue
Stacktrace:
  [1] top-level scope
    @ none:1
  [2] eval
    @ ./boot.jl:360 [inlined]
  [3] maybe_evaluate_builtin(frame::Frame, call_expr::Expr, expand::Bool)
    @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/pJs87/src/builtins.jl:238
  [4] evaluate_call_recurse!(recurse::Any, frame::Frame, call_expr::Expr; enter_generated::Bool)
    @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/pJs87/src/interpret.jl:204
  [5] evaluate_call_recurse!
    @ ~/.julia/packages/JuliaInterpreter/pJs87/src/interpret.jl:201 [inlined]
  [6] eval_rhs(recurse::Any, frame::Frame, node::Expr)
    @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/pJs87/src/interpret.jl:394
  [7] step_expr!(recurse::Any, frame::Frame, node::Any, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/pJs87/src/interpret.jl:537
  [8] step_expr!(recurse::Any, frame::Frame, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/pJs87/src/interpret.jl:587
  [9] finish!(recurse::Any, frame::Frame, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/pJs87/src/commands.jl:14
 [10] finish_and_return!
    @ ~/.julia/packages/JuliaInterpreter/pJs87/src/commands.jl:29 [inlined]
 [11] evaluate_call_recurse!(recurse::Any, frame::Frame, call_expr::Expr; enter_generated::Bool)
    @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/pJs87/src/interpret.jl:239
 [12] evaluate_call_recurse!
    @ ~/.julia/packages/JuliaInterpreter/pJs87/src/interpret.jl:201 [inlined]
 [13] eval_rhs(recurse::Any, frame::Frame, node::Expr)
    @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/pJs87/src/interpret.jl:394
 [14] step_expr!(recurse::Any, frame::Frame, node::Any, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/pJs87/src/interpret.jl:450
 [15] step_expr!(recurse::Any, frame::Frame, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/pJs87/src/interpret.jl:587
 [16] finish!(recurse::Any, frame::Frame, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/pJs87/src/commands.jl:14
 [17] finish_and_return!
    @ ~/.julia/packages/JuliaInterpreter/pJs87/src/commands.jl:29 [inlined]
 [18] evaluate_call_recurse!(recurse::Any, frame::Frame, call_expr::Expr; enter_generated::Bool)
    @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/pJs87/src/interpret.jl:239
 [19] evaluate_call_recurse!
    @ ~/.julia/packages/JuliaInterpreter/pJs87/src/interpret.jl:201 [inlined]
 [20] eval_rhs(recurse::Any, frame::Frame, node::Expr)
    @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/pJs87/src/interpret.jl:394
 [21] step_expr!(recurse::Any, frame::Frame, node::Any, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/pJs87/src/interpret.jl:537
 [22] step_expr!(recurse::Any, frame::Frame, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/pJs87/src/interpret.jl:587
 [23] finish!(recurse::Any, frame::Frame, istoplevel::Bool)
    @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/pJs87/src/commands.jl:14
 [24] finish_and_return!
    @ ~/.julia/packages/JuliaInterpreter/pJs87/src/commands.jl:29 [inlined]
 [25] finish_and_return!
    @ ~/.julia/packages/JuliaInterpreter/pJs87/src/commands.jl:33 [inlined]
 [26] top-level scope
    @ ~/.julia/packages/JuliaInterpreter/pJs87/src/construct.jl:774

timholy added a commit that referenced this issue Dec 16, 2020
This supports SSAValue args for cglobal while also fixing a bug
in which a GotoIfNot ended up going to the wrong statement.
The latter was a consequence of incorrect :call unnesting.

Fixes #455
Fixes #454
Fixes #415
Fixes JuliaDebug/Debugger.jl#275
Improves #354
timholy added a commit that referenced this issue Dec 17, 2020
This supports SSAValue args for cglobal while also fixing a bug
in which a GotoIfNot ended up going to the wrong statement.
The latter was a consequence of incorrect :call unnesting.

Fixes #455
Fixes #454
Fixes #415
Fixes JuliaDebug/Debugger.jl#275
Improves #354
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants