Skip to content

Commit 107e6b0

Browse files
author
Christopher Doris
committed
conversion rule for BaseException to PyException
1 parent 45b8ca0 commit 107e6b0

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

docs/src/conversion-to-julia.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ The following table specifies the conversion rules in place. If the initial Pyth
3434
| `collections.abc.Sequence` (inc. `list`) | `PyList` |
3535
| `collections.abc.Set` (inc. `set`, `frozenset`) | `PySet` |
3636
| `io.IOBase` (includes open files) | `PyIO` |
37+
| `BaseException` | `PyException` |
3738
| `datetime.date`/`datetime.time`/`datetime.datetime` | `Date`/`Time`/`DateTime` |
3839
| `datetime.timedelta` | `Microsecond` (or `Millisecond` or `Second` on overflow) |
3940
| `numpy.intXX`/`numpy.uintXX`/`numpy.floatXX` | `IntXX`/`UIntXX`/`FloatXX` |

src/convert.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ function init_pyconvert()
334334
pyconvert_add_rule("datetime/datetime", DateTime, pyconvert_rule_datetime, 100)
335335
pyconvert_add_rule("datetime/date", Date, pyconvert_rule_date, 100)
336336
pyconvert_add_rule("datetime/time", Time, pyconvert_rule_time, 100)
337+
pyconvert_add_rule("builtins/BaseException", PyException, pyconvert_rule_exception, 100)
337338
# priority 0: reasonable
338339
pyconvert_add_rule("builtins/NoneType", Missing, pyconvert_rule_none)
339340
pyconvert_add_rule("builtins/bool", Number, pyconvert_rule_bool)

src/err.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ export PyException
7070
ispy(x::PyException) = true
7171
getpy(x::PyException) = x.v
7272

73+
pyconvert_rule_exception(::Type{R}, x::Py) where {R<:PyException} = PyException(Py(x))
74+
7375
function Base.show(io::IO, x::PyException)
7476
show(io, typeof(x))
7577
print(io, "(")

0 commit comments

Comments
 (0)