def _import(self, name, fromlist=None): if name in sys.builtin_module_names: raise DataError('Cannot import custom module with same name as ' 'Python built-in module.') invalidate_import_caches() try: return __import__(name, fromlist=fromlist) except: message, traceback = get_error_details(full_traceback=False) path = '\n'.join(f' {p}' for p in sys.path) raise DataError(f'{message}\n{traceback}\nPYTHONPATH:\n{path}')
def _import(self, name, fromlist=None, retry=True): invalidate_import_caches() try: try: return __import__(name, fromlist=fromlist) except ImportError: # Hack to support standalone Jython. For more information, see: # https://github.com/robotframework/robotframework/issues/515 # http://bugs.jython.org/issue1778514 if JYTHON and fromlist and retry: __import__('%s.%s' % (name, fromlist[0])) return self._import(name, fromlist, retry=False) # IronPython loses traceback when using plain raise. # https://github.com/IronLanguages/main/issues/989 if IRONPYTHON: exec('raise sys.exc_type, sys.exc_value, sys.exc_traceback') raise except: raise DataError(*get_error_details())