Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Julia 1.11 prevents assigning objects to Main #582

Open
MilesCranmer opened this issue Jan 1, 2025 · 1 comment · May be fixed by #583
Open

Julia 1.11 prevents assigning objects to Main #582

MilesCranmer opened this issue Jan 1, 2025 · 1 comment · May be fixed by #583
Labels
bug Something isn't working

Comments

@MilesCranmer
Copy link
Contributor

MilesCranmer commented Jan 1, 2025

It looks like this syntax is no longer working on Julia 1.11:

from juliacall import Main as jl

jl.x = 1

On 1.10 of Julia this works, but on 1.11, this raises the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import juliapkg as jp; jp.require_julia("~1.11"); from juliacall import Main as jl; jl.x = 1
                                                                                        ^^^^
  File "/Users/mcranmer/PermaDocuments/PythonCall.jl/src/JlWrap/any.jl", line 254, in __setattr__
    self._jl_callmethod($(pyjl_methodnum(pyjlany_setattr)), k, v)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: Julia: Global Main.x does not exist and cannot be assigned. Declare it using `global` before attempting assignment.

I also verified this error did not depend on Python (3.10 through 3.13 all give the same error).

To quickly verify this:

# 1.10
python -c 'import juliapkg as jp; jp.require_julia("~1.10"); from juliacall import Main as jl; jl.x = 1'
# (Exits fine)

# 1.11
python -c 'import juliapkg as jp; jp.require_julia("~1.11"); from juliacall import Main as jl; jl.x = 1'
# Throws an error

cc @cjdoris

@MilesCranmer
Copy link
Contributor Author

x-post: JuliaLang/julia#56933

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant