Skip to content

Commit 5a8b50f

Browse files
Merge pull request #1315 from Thirumalai-Shaktivel/nested_modules_03
2 parents 2873bd3 + 200313c commit 5a8b50f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

integration_tests/test_import_03.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from test_import import print_a
22
from test_import.test_import_1 import print_b
3+
from test_import.import_module_01.test_import_4 import e
34

45
print(print_a())
56
print(print_b())
7+
print(e)

src/lpython/semantics/python_ast_to_asr.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3408,7 +3408,7 @@ class SymbolTableVisitor : public CommonVisitor<SymbolTableVisitor> {
34083408
// Check for the nested modules with "."
34093409
// Example: from x.y import z
34103410
if (mod_sym.find(".") != std::string::npos) {
3411-
mod_sym.replace(mod_sym.find("."), 1, "/");
3411+
mod_sym = replace(mod_sym, "[.]", "/");
34123412
if(is_directory(paths[0] + "/" + mod_sym)) {
34133413
// Directory i.e., x/y/__init__.py
34143414
paths[0] += '/' + mod_sym;
@@ -3429,7 +3429,7 @@ class SymbolTableVisitor : public CommonVisitor<SymbolTableVisitor> {
34293429
} else if (mod_sym.find(".") != std::string::npos) {
34303430
// Check for the nested modules with "."
34313431
// Example: from x.y import z
3432-
mod_sym.replace(mod_sym.find("."), 1, "/");
3432+
mod_sym = replace(mod_sym, "[.]", "/");
34333433
if(is_directory(paths[1] + "/" + mod_sym)) {
34343434
if (parent_dir != "") paths[1] += "/";
34353435
paths[1] += mod_sym;

0 commit comments

Comments
 (0)