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

Allow multi-block expressions in seval #452

Merged
merged 3 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pytest/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,22 @@ def test_issue_394():
assert jl.f is f
assert jl.y is y
assert jl.seval("f(x)") == 4

def test_issue_433():
"https://github.com/JuliaPy/PythonCall.jl/issues/433"
from juliacall import Main as jl

# Smoke test
jl.seval("x=1\nx=1")
assert jl.x == 1

# Do multiple things
out = jl.seval(
"""
function _issue_433_g(x)
return x^2
end
_issue_433_g(5)
"""
)
assert out == 25
2 changes: 1 addition & 1 deletion src/JlWrap/module.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function pyjlmodule_dir(self::Module)
end

function pyjlmodule_seval(self::Module, expr::Py)
Py(Base.eval(self, Meta.parse(strip(pyconvert(String, expr)))))
Py(Base.eval(self, Meta.parseall(strip(pyconvert(String, expr)))))
end

function init_module()
Expand Down
Loading