Skip to content

Commit

Permalink
Pull Py_CompileString out of disable_sigint
Browse files Browse the repository at this point in the history
Since `Py_CompileString` is unlikely to call Julia callback, there is
no need to put it in `disable_sigint`.  `@pycheckn` for `PyEval_EvalCode`
is in `disable_sigint` because `PyErr_NormalizeException` may call the
constructor of the exception class which may invoke Julia callbacks.

This change may not be necessary but it seems to help Julia compiler
inlining `ccall`.
  • Loading branch information
tkf committed May 10, 2019
1 parent dd2cbe0 commit fffd933
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/pyeval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ pynamespace(m::Module) =
# and a current "file name" to use for stack traces
function pyeval_(s::AbstractString, globals=pynamespace(Main), locals=pynamespace(Main),
input_type=Py_eval_input, fname="PyCall")
disable_sigint() do
o = PyObject(@pycheckn ccall((@pysym :Py_CompileString), PyPtr,
(Cstring, Cstring, Cint),
s, fname, input_type))
return PyObject(@pycheckn ccall((@pysym :PyEval_EvalCode),
PyPtr, (PyPtr, PyPtr, PyPtr),
o, globals, locals))
o = PyObject(@pycheckn ccall((@pysym :Py_CompileString), PyPtr,
(Cstring, Cstring, Cint),
s, fname, input_type))
ptr = disable_sigint() do
@pycheckn ccall((@pysym :PyEval_EvalCode),
PyPtr, (PyPtr, PyPtr, PyPtr),
o, globals, locals)
end
return PyObject(ptr)
end

"""
Expand Down

0 comments on commit fffd933

Please sign in to comment.