Using `@pydef` in a module with `--compile-modules=no`
- 主要言語
- Julia
- スター
- 1.5k
- フォーク
- 186
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I appear to be getting the following error when loading loading my package on 0.7 if I'm running julia 0.7 with `--compile-modules=no`:
```
julia> using Keras
ERROR: LoadError: LoadError: ArgumentError: ref of NULL PyObject
Stacktrace:
[1] getindex(::PyCall.PyObject, ::String) at /Users/rory/.playground/share/keras/depot/packages/PyCall/rUul9/src/PyCall.jl:284
[2] pybuiltin at /Users/rory/.playground/share/keras/depot/packages/PyCall/rUul9/src/PyCall.jl:701 [inlined]
[3] #def_py_class#24(::Array{Any,1}, ::Array{Any,1}, ::Function, ::String, ::Array{Tuple{Symbol,Function},1}) at /Users/rory/.playground/share/keras/depot/packages/PyCall/rUul9/src/pyclass.jl:28
[4] (::getfield(PyCall, Symbol("#kw##def_py_class")))(::NamedTuple{(:base_classes, :getsets),Tuple{Array{Any,1},Array{Any,1}}}, ::typeof(PyCall.def_py_class), ::String, ::Array{Tuple{Symbol,Function},1}) at ./none:0
[5] top-level scope at /Users/rory/.playground/share/keras/depot/packages/PyCall/rUul9/src/pyclass.jl:174
[6] include at ./boot.jl:317 [inlined]
[7] include_relative(::Module, ::String) at ./loading.jl:1038
[8] include at ./sysimg.jl:29 [inlined]
[9] include(::String) at /Users/rory/repos/Keras.jl/src/Keras.jl:1
[10] top-level scope at none:0
[11] include at ./boot.jl:317 [inlined]
[12] include_relative(::Module, ::String) at ./loading.jl:1038
[13] _require(::Base.PkgId) at ./loading.jl:950
[14] require(::Base.PkgId) at ./loading.jl:852
[15] macro expansion at ./logging.jl:311 [inlined]
[16] require(::Module, ::Symbol) at ./loading.jl:834
in expression starting at /Users/rory/repos/Keras.jl/src/utils.jl:1
in expression starting at /Users/rory/repos/Keras.jl/src/Keras.jl:78
```
The issue appears to be with:
```
@pydef mutable struct metric
function __init__(self, f::Function, name=nothing)
self[:f] = f
self[:__name__] = name == nothing ? typeof(f).name.mt.name : name
end
function __call__(self, x::PyObject, y::PyObject)
self[:f](Tensor(x), Tensor(y)).o
end
end
```
General observations:
- After getting the above error `pybuiltin("object")` stops working, and produces the same `ArgumentError: ref of NULL PyObject` error.
- Running `using PyCall` before `using Keras` works.
- Running julia normally (e.g., without `--compile-module=no`) also works.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
Julia 0.7 で --compile-modules=no を指定して失敗を再現し、`using Keras` と、先に PyCall を読み込んだ場合を比較してください。`src/pyclass.jl` の `def_py_class` 付近と `@pydef` の例から始め、その後、通常の読み込みは引き続き動作する一方で、`using Keras` が `ref of NULL PyObject` を発生させなくなっていることを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- julia, python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100