Skip to content

Commit

Permalink
Merge branch 'master' into allow_creating_env_without_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
alonre24 authored Nov 21, 2023
2 parents 6f490c5 + 803b916 commit 9a898e9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions RLTest/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(self, filename, symbol, modulename):
def initialize(self):
module_spec = importlib.util.spec_from_file_location(self.modulename, self.filename)
module = importlib.util.module_from_spec(module_spec)
sys.modules[self.modulename] = module
module_spec.loader.exec_module(module)
obj = getattr(module, self.symbol)
self.target = obj
Expand Down Expand Up @@ -53,6 +54,7 @@ def __init__(self, filename, symbol, modulename, functions):
def initialize(self):
module_spec = importlib.util.spec_from_file_location(self.modulename, self.filename)
module = importlib.util.module_from_spec(module_spec)
sys.modules[self.modulename] = module
module_spec.loader.exec_module(module)
obj = getattr(module, self.symbol)
self.clsname = obj.__name__
Expand Down Expand Up @@ -117,6 +119,7 @@ def load_files(self, module_dir, module_name, toplevel_filter=None, subfilter=No
try:
module_spec = importlib.util.spec_from_file_location(module_name, filename)
module = importlib.util.module_from_spec(module_spec)
sys.modules[module_name] = module
module_spec.loader.exec_module(module)
for symbol in dir(module):
if not self.filter_modulevar(symbol, toplevel_filter):
Expand Down

0 comments on commit 9a898e9

Please sign in to comment.