def import_module(self, module):
'''Import a module into the evaluator.
Note: Import only trustworthy modules! Module imports are global,
therefore, importing a malicious module which manipulates other global
modules could affect code behaviour outside of the Evaluator as well.
Args:
module (str): Python module to import.
Raises:
FyppFatalError: If module could not be imported.
'''
rootmod = module.split('.', 1)[0]
try:
imported = __import__(module, self._scope)
self.define(rootmod, imported)
except Exception as exc:
msg = "failed to import module '{0}'".format(module)
raise FyppFatalError(msg, cause=exc)
评论列表
文章目录