Skip to content

Commit 927b0aa

Browse files
committed
Fix JuliaMainModule.__setattr__
1 parent 00d542d commit 927b0aa

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

julia/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def __setattr__(self, name, value):
140140
juliapath = remove_prefix(self.__name__, "julia.")
141141
setter = '''
142142
PyCall.pyfunctionret(
143-
(x) -> eval({}, :({} = $x)),
143+
(x) -> Base.eval({}, :({} = $x)),
144144
Any,
145145
PyCall.PyAny)
146146
'''.format(juliapath, jl_name(name))

test/test_python_jl.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from textwrap import dedent
12
import os
23
import subprocess
34

@@ -59,10 +60,22 @@ def test_cli_quick_pass_no_julia(cli_args):
5960
not PYJULIA_TEST_REBUILD,
6061
reason="PYJULIA_TEST_REBUILD=yes is not set")
6162
def test_cli_import():
62-
cli_args = ["-c", "from julia import Base; Base.banner()"]
63+
cli_args = ["-c", dedent("""
64+
from julia import Base
65+
Base.banner()
66+
from julia import Main
67+
Main.x = 1
68+
assert Main.x == 1
69+
""")]
6370
if JULIA:
6471
cli_args = ["--julia", JULIA] + cli_args
6572
output = subprocess.check_output(
6673
["python-jl"] + cli_args,
6774
universal_newlines=True)
6875
assert "julialang.org" in output
76+
77+
# Embedded julia does not have usual the Main.eval and Main.include.
78+
# Main.eval is Core.eval. Let's test that we are not relying on this
79+
# special behavior.
80+
#
81+
# See also: https://github.com/JuliaLang/julia/issues/28825

0 commit comments

Comments
 (0)