@@ -82,7 +82,7 @@ def __eq__(self, other):
8282 return self .name == other .name and self .version == other .version
8383
8484 def __repr__ (self ):
85- return '%s(%s)' % ( type (self ).__name__ , self .fullname )
85+ return f' { type (self ).__name__ } ( { self . fullname } , { self .collection } )'
8686
8787 def __str__ (self ):
8888 return self .fullname
@@ -222,15 +222,20 @@ def load_module(self, name, force=False, collection=False):
222222 conflicting modules currently loaded. If module ``name`` refers to
223223 multiple real modules, all of the target modules will be loaded.
224224 :arg collection: The module is a "module collection" (TMod4 only)
225- :returns: the list of unloaded modules as strings.
225+ :returns: A list of two-element tuples, where each tuple contains the
226+ module that was loaded and the list of modules that had to be
227+ unloaded first due to conflicts. This list will be normally of
228+ size one, but it can be longer if there is mapping that maps
229+ module ``name`` to multiple other modules.
226230
227231 .. versionchanged:: 3.3
228- The ``collection`` argument was added.
232+ - The ``collection`` argument was added.
233+ - This function now returns a list of tuples.
229234
230235 '''
231236 ret = []
232237 for m in self .resolve_module (name ):
233- ret += self ._load_module (m , force , collection )
238+ ret . append (( m , self ._load_module (m , force , collection )) )
234239
235240 return ret
236241
@@ -349,37 +354,41 @@ def searchpath_remove(self, *dirs):
349354 return self ._backend .searchpath_remove (* dirs )
350355
351356 def emit_load_commands (self , name , collection = False ):
352- '''Return the appropriate shell command for loading module ``name``.
357+ '''Return the appropriate shell commands for loading a module.
358+
359+ Module mappings are not taken into account by this function.
353360
354361 :arg name: The name of the module to load.
355362 :arg collection: The module is a "module collection" (TMod4 only)
356363 :returns: A list of shell commands.
357364
358365 .. versionchanged:: 3.3
359- The ``collection`` argument was added.
366+ The ``collection`` argument was added and module mappings are no
367+ more taken into account by this function.
360368
361369 '''
362- ret = []
363- for name in self .resolve_module (name ):
364- cmds = self ._backend .emit_load_instr (Module (name , collection ))
365- if cmds :
366- ret .append (cmds )
367370
368- return ret
371+ # We don't consider module mappings here, because we cannot treat
372+ # correctly possible conflicts
373+ return [self ._backend .emit_load_instr (Module (name , collection ))]
369374
370375 def emit_unload_commands (self , name , collection = False ):
371- '''Return the appropriate shell command for unloading module
372- ``name``.
376+ '''Return the appropriate shell commands for unloading a module.
377+
378+ Module mappings are not taken into account by this function.
379+
380+ :arg name: The name of the module to unload.
381+ :arg collection: The module is a "module collection" (TMod4 only)
382+ :returns: A list of shell commands.
383+
384+ .. versionchanged:: 3.3
385+ The ``collection`` argument was added and module mappings are no
386+ more taken into account by this function.
373387
374- :rtype: List[str]
375388 '''
376- ret = []
377- for name in self .resolve_module (name ):
378- cmds = self ._backend .emit_unload_instr (Module (name , collection ))
379- if cmds :
380- ret .append (cmds )
381389
382- return ret
390+ # See comment in emit_load_commands()
391+ return [self ._backend .emit_unload_instr (Module (name , collection ))]
383392
384393 def __str__ (self ):
385394 return str (self ._backend )
0 commit comments