@@ -191,7 +191,7 @@ def __try_getattr(self, name):
191191 if self ._julia .isamodule (jl_fullname ):
192192 realname = self ._julia .fullname (self ._julia .eval (jl_fullname ))
193193 if self ._julia .isdefined (realname ):
194- return self .__loader__ .load_module ( "julia." + realname )
194+ return self .__loader__ .create_module ( _find_spec_from_fullname ( "julia." + realname ) )
195195 # Otherwise, it may be, e.g., "Main.anonymous", created by
196196 # Module().
197197
@@ -225,14 +225,17 @@ def __setattr__(self, name, value):
225225class JuliaImporter (MetaPathFinder ):
226226
227227 def find_spec (self , fullname , path = None , target = None ):
228- if fullname .startswith ("julia." ):
229- filename = fullname .split ("." , 2 )[1 ]
230- filepath = os .path .join (os .path .dirname (__file__ ), filename )
231- if os .path .isfile (filepath + ".py" ) or os .path .isdir (filepath ):
232- return
233- return ModuleSpec (fullname , JuliaModuleLoader (), origin = filepath )
228+ return _find_spec_from_fullname (fullname )
234229
235230
231+ def _find_spec_from_fullname (fullname ):
232+ if fullname .startswith ("julia." ):
233+ filename = fullname .split ("." , 2 )[1 ]
234+ filepath = os .path .join (os .path .dirname (__file__ ), filename )
235+ if os .path .isfile (filepath + ".py" ) or os .path .isdir (filepath ):
236+ return
237+ return ModuleSpec (fullname , JuliaModuleLoader (), origin = filepath )
238+
236239class JuliaModuleLoader (Loader ):
237240 @property
238241 def julia (self ):
0 commit comments