JuliaPy / JuliaPy/PyCall.jl

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

Open
#409 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
1.5k
Forks
186
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the @pydef examples using pybuiltin(:super) in the generated __str__ method, comparing the zero-argument and explicit-argument forms. Trace how these entry points invoke Python and determine what is needed for the zero-argument form to work; done means the first example no longer raises RuntimeError while the manual form remains working.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia, python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.