JuliaPy / JuliaPy/PyCall.jl

zero-arg call to Python `super()` not working

Aperta
#409 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Julia
Stelle
1.5k
Fork
186
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

As the title says, the zero-arg version of `super()` doesn't work,

```julia
julia> @pydef type Foo
__str__(self) = pybuiltin(:super)()[:__str__]()
end
PyObject

julia> Foo()[:__str__]()
ERROR: PyError (ccall(@pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, arg, C_NULL))
RuntimeError('super(): no arguments',)
File "PyCall", line 1, in

Stacktrace:
[1] pyerr_check at /home/marius/.julia/v0.6/PyCall/src/exception.jl:56 [inlined]
[2] pyerr_check at /home/marius/.julia/v0.6/PyCall/src/exception.jl:61 [inlined]
[3] macro expansion at /home/marius/.julia/v0.6/PyCall/src/exception.jl:81 [inlined]
[4] #_pycall#66(::Array{Any,1}, ::Function, ::PyCall.PyObject) at /home/marius/.julia/v0.6/PyCall/src/PyCall.jl:620
[5] #pycall#70(::Array{Any,1}, ::Function, ::PyCall.PyObject, ::Type{PyCall.PyAny}) at /home/marius/.julia/v0.6/PyCall/src/PyCall.jl:642
[6] #call#71 at /home/marius/.julia/v0.6/PyCall/src/PyCall.jl:645 [inlined]
[7] (::PyCall.PyObject)() at /home/marius/.julia/v0.6/PyCall/src/PyCall.jl:645
```

although the manual version is fine,

```julia
julia> @pydef type Bar
__str__(self) = pybuiltin(:super)(Bar,self)[:__str__]()
end
PyObject

julia> Bar()[:__str__]()
""
```

I'm guessing what's happening is described by [this](https://stackoverflow.com/a/39313448/1078529) answer,

> The zero-argument form of super requires that the method containing it have an explicit (i.e., non-varargs) first argument

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.