Skip to content

Passing PyObject through include/eval turns it into PyNULL (which causes segfaults) #551

Closed
@tkf

Description

@tkf
julia> using PyCall

julia> obj = pyimport("sys")  # get some PyObject
PyObject <module 'sys' (built-in)>

julia> py"""
       ns = {}
       def set(name):
           ns[name] = $include_string($Main, name)
       """

julia> py"set"("obj")

julia> obj
PyObject NULL

julia> py"lambda x: x"(obj)

signal (11): Segmentation fault

There are two problems: (1) py"set"("obj") turns obj to PyNULL (ref count issue?) and (2) passing PyNULL to Python function is not guarded enough.

Note that py"set" is modeling what we do in PyJulia all the time so it's not a contrived example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions