Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
fix: sys.module dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
AshishMahendra committed Aug 27, 2024
1 parent 3f4b8dc commit 21c56bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions jaclang/runtimelib/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def run_import(self, spec: ImportPathSpec) -> ImportReturn:
def update_sys(self, module: types.ModuleType, spec: ImportPathSpec) -> None:
"""Update sys.modules with the newly imported module."""
if spec.module_name not in self.jac_machine.loaded_modules:
self.jac_machine.loaded_modules[spec.module_name] = module
self.jac_machine.load_module(spec.module_name, module)


class PythonImporter(Importer):
Expand Down Expand Up @@ -305,7 +305,7 @@ def handle_directory(
module.__file__ = None

if module_name not in self.jac_machine.loaded_modules:
self.jac_machine.loaded_modules[module_name] = module
self.jac_machine.load_module(module_name, module)
return module

def create_jac_py_module(
Expand All @@ -331,7 +331,7 @@ def create_jac_py_module(
module_name=package_name,
full_mod_path=full_mod_path,
)
self.jac_machine.loaded_modules[module_name] = module
self.jac_machine.load_module(module_name, module)
return module

def run_import(
Expand Down
2 changes: 2 additions & 0 deletions jaclang/runtimelib/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import inspect
import marshal
import os
import sys
import types
from typing import Dict, Optional

Expand Down Expand Up @@ -59,6 +60,7 @@ def get_bytecode(
def load_module(self, module_name: str, module: types.ModuleType) -> None:
"""Load a module into the machine."""
self.loaded_modules[module_name] = module
sys.modules[module_name] = module

def list_modules(self) -> list[str]:
"""List all loaded modules."""
Expand Down

0 comments on commit 21c56bc

Please sign in to comment.