diff --git a/integration_tests/test_import_03.py b/integration_tests/test_import_03.py index 1b17f8e610..f37e890d74 100644 --- a/integration_tests/test_import_03.py +++ b/integration_tests/test_import_03.py @@ -1,5 +1,7 @@ from test_import import print_a from test_import.test_import_1 import print_b +from test_import.import_module_01.test_import_4 import e print(print_a()) print(print_b()) +print(e) diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index fc01941b90..0c003330e9 100644 --- a/src/lpython/semantics/python_ast_to_asr.cpp +++ b/src/lpython/semantics/python_ast_to_asr.cpp @@ -3408,7 +3408,7 @@ class SymbolTableVisitor : public CommonVisitor { // Check for the nested modules with "." // Example: from x.y import z if (mod_sym.find(".") != std::string::npos) { - mod_sym.replace(mod_sym.find("."), 1, "/"); + mod_sym = replace(mod_sym, "[.]", "/"); if(is_directory(paths[0] + "/" + mod_sym)) { // Directory i.e., x/y/__init__.py paths[0] += '/' + mod_sym; @@ -3429,7 +3429,7 @@ class SymbolTableVisitor : public CommonVisitor { } else if (mod_sym.find(".") != std::string::npos) { // Check for the nested modules with "." // Example: from x.y import z - mod_sym.replace(mod_sym.find("."), 1, "/"); + mod_sym = replace(mod_sym, "[.]", "/"); if(is_directory(paths[1] + "/" + mod_sym)) { if (parent_dir != "") paths[1] += "/"; paths[1] += mod_sym;