Skip to content

failure on 0.6 in anonymous callback #343

@stevengj

Description

@stevengj

In Julia 0.6 master, I can successfully convert an ordinary function like sum and call it from Python: PyObject(sum)(3) works (and returns 3).

However, the same code no longer works for anonymous functions: PyObject(x -> x+1)(3) fails. I inserted some println statements into the callback hook, and I verified that f = unsafe_pyjlwrap_to_objref(self_)::Function is successfully getting a reference to f = x -> x+1 (display(f) gives the expected output). However, for some reasons f(3) is then throwing a MethodError.

@vtjnash, @yuyichao, has something changed at a low-level with Function objects, e.g. the new dependency-tracking stuff, that would break this?

(I'm stashing a jl_value_t* pointer in the Python object and pulling it out in the callback to call; a reference to the function object is saved in a global dictionary to prevent it from being garbage-collected.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions