@@ -191,7 +191,7 @@ def __try_getattr(self, name):
191
191
if self ._julia .isamodule (jl_fullname ):
192
192
realname = self ._julia .fullname (self ._julia .eval (jl_fullname ))
193
193
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 ) )
195
195
# Otherwise, it may be, e.g., "Main.anonymous", created by
196
196
# Module().
197
197
@@ -225,14 +225,17 @@ def __setattr__(self, name, value):
225
225
class JuliaImporter (MetaPathFinder ):
226
226
227
227
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 )
234
229
235
230
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
+
236
239
class JuliaModuleLoader (Loader ):
237
240
@property
238
241
def julia (self ):
0 commit comments