Skip to content

Commit 2338c68

Browse files
committed
wrap sprint in try-catch block and print in debug
1 parent 83a21bb commit 2338c68

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/cpython/jlwrap.jl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,12 @@ function _pyjl_serialize(self::PyPtr, ::PyPtr)
205205
b = take!(io)
206206
return PyBytes_FromStringAndSize(pointer(b), sizeof(b))
207207
catch e
208-
PyErr_SetString(
209-
POINTERS.PyExc_Exception,
210-
"error serializing this value. Caught exception $(sprint(showerror, e, catch_backtrace()))"
211-
)
208+
PyErr_SetString(POINTERS.PyExc_Exception, "error serializing this value.")
209+
# wrap sprint in another try-catch block to prevent this function from throwing
210+
try
211+
@debug "Caught exception $(sprint(showerror, e, catch_backtrace()))"
212+
catch
213+
end
212214
return PyNULL
213215
end
214216
end
@@ -223,10 +225,12 @@ function _pyjl_deserialize(t::PyPtr, v::PyPtr)
223225
x = deserialize(io)
224226
return PyJuliaValue_New(t, x)
225227
catch e
226-
PyErr_SetString(
227-
POINTERS.PyExc_Exception,
228-
"error deserializing this value. Caught exception $(sprint(showerror, e, catch_backtrace()))"
229-
)
228+
PyErr_SetString(POINTERS.PyExc_Exception, "error deserializing this value.")
229+
# wrap sprint in another try-catch block to prevent this function from throwing
230+
try
231+
@debug "Caught exception $(sprint(showerror, e, catch_backtrace()))"
232+
catch
233+
end
230234
return PyNULL
231235
end
232236
end

0 commit comments

Comments
 (0)