Skip to content

Passing functions to Julia as global variables is buggy #394

Closed
@LilithHafner

Description

@LilithHafner

Affects: JuliaCall

Describe the bug
Passing functions to Julia as global variables is buggy

>>> from juliacall import Main
>>> Main.x = 5
>>> Main.x # Fine
5
>>> def f(y):
...     return y + 1
... 
>>> Main.f = f
>>> Main.f # Bad
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/x/.julia/packages/PythonCall/qTEA1/src/jlwrap/any.jl", line 195, in __getattr__
    return self._jl_callmethod($(pyjl_methodnum(pyjlany_getattr)), k)
       ^^^^^^^^^^^^^^^^^^^^^^^^^^
SystemError: <built-in method _jl_callmethod of ModuleValue object at 0x103dc7a00> returned NULL without setting an exception
>>> Main.z = 7
>>> Main.z
7
>>> Main.f  # Very bad
7
>>> Main.x
5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions