Skip to content

Commit 8ee3479

Browse files
author
Christopher Doris
committed
add PyException to the API
1 parent 52a6170 commit 8ee3479

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

src/API/exports.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Core
22
export Py
33
export ispy
4+
export PyException
45
export pyis
56
export pyrepr
67
export pyascii

src/API/types.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,15 @@ mutable struct Py
2626
ptr::Ptr{Cvoid}
2727
Py(::Val{:new}, ptr::Ptr{Cvoid}) = finalizer(Core.py_finalizer, new(ptr))
2828
end
29+
30+
"""
31+
PyException(x)
32+
33+
Wraps the Python exception `x` as a Julia `Exception`.
34+
"""
35+
mutable struct PyException <: Exception
36+
_t::Py
37+
_v::Py
38+
_b::Py
39+
_isnormalized::Bool
40+
end

src/Core/Core.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ using MacroTools: MacroTools, @capture
3131
using Markdown: Markdown
3232

3333
import ..PythonCall:
34+
Py,
35+
PyException,
3436
pynew,
3537
pyisnull,
3638
pycopy!,

src/Core/err.jl

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,6 @@ function errnormalize!(t::Py, v::Py, b::Py)
4343
(t, v, b)
4444
end
4545

46-
"""
47-
PyException(x)
48-
49-
Wraps the Python exception `x` as a Julia `Exception`.
50-
"""
51-
mutable struct PyException <: Exception
52-
_t::Py
53-
_v::Py
54-
_b::Py
55-
_isnormalized::Bool
56-
end
5746
function PyException(v::Py = pybuiltins.None)
5847
if pyisnone(v)
5948
t = b = v
@@ -65,7 +54,6 @@ function PyException(v::Py = pybuiltins.None)
6554
end
6655
PyException(t, v, b, true)
6756
end
68-
export PyException
6957

7058
ispy(x::PyException) = true
7159
Py(x::PyException) = x.v

0 commit comments

Comments
 (0)