Skip to content

Commit a0f461d

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

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/cpython/jlwrap.jl

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,13 @@ 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 e2
213+
@debug "Error printing exception: $e2"
214+
end
212215
return PyNULL
213216
end
214217
end
@@ -223,10 +226,13 @@ function _pyjl_deserialize(t::PyPtr, v::PyPtr)
223226
x = deserialize(io)
224227
return PyJuliaValue_New(t, x)
225228
catch e
226-
PyErr_SetString(
227-
POINTERS.PyExc_Exception,
228-
"error deserializing this value. Caught exception $(sprint(showerror, e, catch_backtrace()))"
229-
)
229+
PyErr_SetString(POINTERS.PyExc_Exception, "error deserializing this value")
230+
# wrap sprint in another try-catch block to prevent this function from throwing
231+
try
232+
@debug "Caught exception $(sprint(showerror, e, catch_backtrace()))"
233+
catch e2
234+
@debug "Error printing exception: $e2"
235+
end
230236
return PyNULL
231237
end
232238
end

0 commit comments

Comments
 (0)