Skip to content

Commit

Permalink
Fix JuliaMainModule.__setattr__
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Oct 24, 2018
1 parent 5500648 commit 1aa0a1f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion julia/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def __setattr__(self, name, value):
juliapath = remove_prefix(self.__name__, "julia.")
setter = '''
PyCall.pyfunctionret(
(x) -> eval({}, :({} = $x)),
(x) -> Base.eval({}, :({} = $x)),
Any,
PyCall.PyAny)
'''.format(juliapath, jl_name(name))
Expand Down
15 changes: 14 additions & 1 deletion test/test_python_jl.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from textwrap import dedent
import os
import subprocess

Expand Down Expand Up @@ -59,10 +60,22 @@ def test_cli_quick_pass_no_julia(cli_args):
not PYJULIA_TEST_REBUILD,
reason="PYJULIA_TEST_REBUILD=yes is not set")
def test_cli_import():
cli_args = ["-c", "from julia import Base; Base.banner()"]
cli_args = ["-c", dedent("""
from julia import Base
Base.banner()
from julia import Main
Main.x = 1
assert Main.x == 1
""")]
if JULIA:
cli_args = ["--julia", JULIA] + cli_args
output = subprocess.check_output(
["python-jl"] + cli_args,
universal_newlines=True)
assert "julialang.org" in output

# Embedded julia does not have usual the Main.eval and Main.include.
# Main.eval is Core.eval. Let's test that we are not relying on this
# special behavior.
#
# See also: https://github.com/JuliaLang/julia/issues/28825

0 comments on commit 1aa0a1f

Please sign in to comment.