File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -436,7 +436,7 @@ function pyimport(name::AbstractString)
436436 if ispynull (o)
437437 if pyerr_occurred ()
438438 e = PyError (" PyImport_ImportModule" )
439- if e . T . o == @pyglobalobjptr (:PyExc_ImportError )
439+ if pyisinstance (e . val, @pyglobalobjptr (:PyExc_ImportError ) )
440440 # Expand message to help with common user confusions.
441441 msg = """
442442The Python package $name could not be found by pyimport. Usually this means
Original file line number Diff line number Diff line change @@ -321,6 +321,18 @@ const PyInt = pyversion < v"3" ? Int : Clonglong
321321 @test ! ispynull (PyObject (3 ))
322322 @test ispynull (pydecref (PyObject (3 )))
323323
324+ ex = try
325+ pyimport (" s p a m" )
326+ catch ex
327+ ex
328+ end
329+ @test ex isa PyCall. PyError
330+ @test occursin (" could not be found by pyimport" , ex. msg)
331+ # Make sure we are testing ModuleNotFoundError here:
332+ if PyCall. pyversion >= v " 3.6"
333+ @test pyisinstance (ex. val, pybuiltin (" ModuleNotFoundError" ))
334+ end
335+
324336 @test ! ispynull (pyimport_conda (" inspect" , " not a conda package" ))
325337 import Conda
326338 if PyCall. conda
You can’t perform that action at this time.
0 commit comments