@@ -13,14 +13,11 @@ struct PyError <: Exception
13
13
# PyErr_Occurred returns non-NULL, and clears the Python error
14
14
# indicator.
15
15
function PyError (msg:: AbstractString )
16
- exc = Array {PyPtr} (undef, 3 )
17
- pexc = convert (UInt, pointer (exc))
16
+ ptype, pvalue, ptraceback = Ref {PyPtr} (), Ref {PyPtr} (), Ref {PyPtr} ()
18
17
# equivalent of passing C pointers &exc[1], &exc[2], &exc[3]:
19
- ccall ((@pysym :PyErr_Fetch ), Cvoid, (UInt,UInt,UInt),
20
- pexc, pexc + sizeof (PyPtr), pexc + 2 * sizeof (PyPtr))
21
- ccall ((@pysym :PyErr_NormalizeException ), Cvoid, (UInt,UInt,UInt),
22
- pexc, pexc + sizeof (PyPtr), pexc + 2 * sizeof (PyPtr))
23
- new (msg, PyObject (exc[1 ]), PyObject (exc[2 ]), PyObject (exc[3 ]))
18
+ ccall ((@pysym :PyErr_Fetch ), Cvoid, (Ref{PyPtr},Ref{PyPtr},Ref{PyPtr}), ptype, pvalue, ptraceback)
19
+ ccall ((@pysym :PyErr_NormalizeException ), Cvoid, (Ref{PyPtr},Ref{PyPtr},Ref{PyPtr}), ptype, pvalue, ptraceback)
20
+ new (msg, PyObject (ptype[]), PyObject (pvalue[]), PyObject (ptraceback[]))
24
21
end
25
22
26
23
PyError (msg:: AbstractString , e:: PyError ) = new (msg, e. T, e. val, e. traceback)
@@ -203,4 +200,4 @@ used in a `catch` block so that `catch_backtrace()` is valid.
203
200
"""
204
201
macro pyraise (e)
205
202
:(pyraise ($ (esc (e)), catch_backtrace ()))
206
- end
203
+ end
0 commit comments