Skip to content

Commit 46b15d7

Browse files
authored
give pytype_mapping precendence over default mappings (#792)
1 parent 14f77cc commit 46b15d7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/conversions.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,11 @@ native Julia type (defaulting to `default`) that we convert
800800
function pytype_query(o::PyObject, default::TypeTuple=PyObject)
801801
# TODO: Use some kind of hashtable (e.g. based on PyObject_Type(o)).
802802
# (A bit tricky to correctly handle Tuple and other containers.)
803+
for (py,jl) in pytype_queries
804+
if pyisinstance(o, py)
805+
return jl
806+
end
807+
end
803808
@return_not_None pyint_query(o)
804809
pyisinstance(o, npy_bool) && return Bool
805810
@return_not_None pyfloat_query(o)
@@ -812,11 +817,6 @@ function pytype_query(o::PyObject, default::TypeTuple=PyObject)
812817
@return_not_None pysequence_query(o)
813818
@return_not_None pynothing_query(o)
814819
@return_not_None pymp_query(o)
815-
for (py,jl) in pytype_queries
816-
if pyisinstance(o, py)
817-
return jl
818-
end
819-
end
820820
return default
821821
end
822822

0 commit comments

Comments
 (0)