Skip to content

Commit d333936

Browse files
WIP
1 parent 0ab254e commit d333936

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

a/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from .b import print_b
1+
from .b import print_a, print_b
22
from .c import print_c

a/b.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
def print_a() -> str:
2+
return "A"
3+
14
def print_b() -> str:
25
return "B"

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3070,6 +3070,13 @@ class SymbolTableVisitor : public CommonVisitor<SymbolTableVisitor> {
30703070
st = st->parent;
30713071
}
30723072
bool ltypes, enum_py;
3073+
if (!std::filesystem::exists(std::filesystem::path(paths[0]+'/'+msym+".py"))
3074+
&& import_path != "") {
3075+
paths = {import_path + '/' + msym};
3076+
if(std::filesystem::is_directory(std::filesystem::path(paths[0]))) {
3077+
msym = "__init__";
3078+
}
3079+
}
30733080
t = (ASR::symbol_t*)(load_module(al, st,
30743081
msym, x.base.base.loc, false, paths, ltypes, enum_py,
30753082
[&](const std::string &msg, const Location &loc) { throw SemanticError(msg, loc); }

test_a.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import a
2+
from a import print_a
23

4+
print(print_a())
5+
print(a.print_a())
36
print(a.print_b())
47
print(a.print_c())
58

69
# import platform
710
# print(platform.python_version())
8-

0 commit comments

Comments
 (0)