From 7baf64e67c7c88f736aff9a3329c69fe4723a137 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Thu, 6 Aug 2026 00:13:25 +0800 Subject: [PATCH 1/2] Update vm.c --- src/interpreter/vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interpreter/vm.c b/src/interpreter/vm.c index ca2e182e..d8b0827d 100644 --- a/src/interpreter/vm.c +++ b/src/interpreter/vm.c @@ -195,7 +195,7 @@ void VM__ctor(VM* self) { INJECT_BUILTIN_EXC(SyntaxError, tp_Exception); INJECT_BUILTIN_EXC(RecursionError, tp_Exception); INJECT_BUILTIN_EXC(OSError, tp_Exception); - INJECT_BUILTIN_EXC(PermissionError, tp_OSError); + INJECT_BUILTIN_EXC(PermissionError, tp_Exception); INJECT_BUILTIN_EXC(NotImplementedError, tp_Exception); INJECT_BUILTIN_EXC(TypeError, tp_Exception); INJECT_BUILTIN_EXC(IndexError, tp_Exception); From 6d45b633d81b2370f19c91c389ebf25ce564985a Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Tue, 11 Aug 2026 17:01:42 +0800 Subject: [PATCH 2/2] fix import multi --- src/compiler/compiler.c | 2 ++ src/public/ModuleSystem.c | 11 +++++++++++ tests/302_import_multi.py | 4 ++++ 3 files changed, 17 insertions(+) create mode 100644 tests/302_import_multi.py diff --git a/src/compiler/compiler.c b/src/compiler/compiler.c index 3a3491ed..62f27763 100644 --- a/src/compiler/compiler.c +++ b/src/compiler/compiler.c @@ -2547,6 +2547,8 @@ static Error* compile_normal_import(Compiler* self, c11_sbuf* buf) { } c11_string* path = c11_sbuf__submit(buf); + c11_sbuf__ctor(buf); + int path_index = Ctx__add_const_string(ctx(), c11_string__sv(path)); c11_string__delete(path); diff --git a/src/public/ModuleSystem.c b/src/public/ModuleSystem.c index e50754bf..ebd6eb27 100644 --- a/src/public/ModuleSystem.c +++ b/src/public/ModuleSystem.c @@ -56,8 +56,19 @@ static void py_ModuleInfo__dtor(py_ModuleInfo* mi) { c11_string__delete(mi->path); } +static bool module__repr__(int argc, py_Ref argv) { + PY_CHECK_ARGC(1); + py_ModuleInfo* self = py_touserdata(argv); + c11_sbuf buf; + c11_sbuf__ctor(&buf); + pk_sprintf(&buf, "", self->path->data); + c11_sbuf__py_submit(&buf, py_retval()); + return true; +} + py_Type pk_module__register() { py_Type type = pk_newtype("module", tp_object, NULL, (py_Dtor)py_ModuleInfo__dtor, false, true); + py_bindmagic(type, __repr__, module__repr__); return type; } diff --git a/tests/302_import_multi.py b/tests/302_import_multi.py new file mode 100644 index 00000000..3bfa041a --- /dev/null +++ b/tests/302_import_multi.py @@ -0,0 +1,4 @@ +import os, math + +assert repr(os) == "" +assert repr(math) == ""