zero-arg call to Python `super()` not working
- Vorherrschende Sprache
- Julia
- Sterne
- 1.5k
- Forks
- 186
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.