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

PyCall.PyJlError has no field msg #1021

Closed
lgeissbauer-btig opened this issue Jan 9, 2023 · 1 comment · Fixed by #1022
Closed

PyCall.PyJlError has no field msg #1021

lgeissbauer-btig opened this issue Jan 9, 2023 · 1 comment · Fixed by #1022

Comments

@lgeissbauer-btig
Copy link

julia> JET.@report_call pyimport("snowflake.connector")
═════ 2 possible errors found ═════
┌ @ C:\.julia\packages\PyCall\9Nvls\src\PyCall.jl:556 e.msg
│┌ @ Base.jl:38 Base.getfield(x, f)
││ type PyCall.PyJlError has no field msg
│└──────────────
┌ @ C:\.julia\packages\PyCall\9Nvls\src\PyCall.jl:556 e = PyCall.pyerror(PyCall.string(e.msg, "\n\n", msg, "\n"), e)
│ no matching method found `pyerror(::String, ::PyCall.PyJlError)` (1/2 union split): e = PyCall.pyerror(PyCall.string((e::Union{PyCall.PyError, PyCall.PyJlError}).msg::String, "\n\n", msg::String, "\n")::String, e::Union{PyCall.PyError, PyCall.PyJlError})
└─────────────────────────────────────────────────────

aviatesk/JET.jl#450

@stevengj
Copy link
Member

stevengj commented Jan 9, 2023

The object e is created by e = pyerror("PyImport_ImportModule"). I think JET is upset by the fact that pyerror is currently type-unstable: it may return either an instance of PyError or PyJlError, but the latter only occurs in pyjlwrap callbacks. In pyimport it should always be a PyError, in which case it has a msg field and this is safe.

So, I don't think this is a bug in PyCall. But probably the code could be cleaned up so that in pyimport we call a version of pyerror that is guaranteed to return a PyError object.

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