Compare commits

...

2 Commits

Author SHA1 Message Date
blueloveTH
054fcba7e4 fix gc bug 2025-08-26 00:51:55 +08:00
blueloveTH
0c897df2c6 backup 2025-08-26 00:48:58 +08:00
3 changed files with 18 additions and 4 deletions

View File

@ -3,7 +3,7 @@
void pk_print_stack(VM* self, py_Frame* frame, Bytecode byte) {
return;
if(frame == NULL || py_isnil(self->main)) return;
if(frame == NULL || !self->main || py_isnil(self->main)) return;
py_TValue* sp = self->stack.sp;
c11_sbuf buf;

View File

@ -47,7 +47,10 @@ void py_newellipsis(py_OutRef out) {
out->is_ptr = false;
}
void py_newnil(py_OutRef out) { out->type = 0; }
void py_newnil(py_OutRef out) {
out->type = tp_nil;
out->is_ptr = false;
}
void py_newnativefunc(py_OutRef out, py_CFunction f) {
out->type = tp_nativefunc;

View File

@ -16,7 +16,6 @@ d.__path__ = '__main__'
d.a = []
d.gc = 1
print('-' * 100)
assert d.gc == 1
del d.a
@ -32,4 +31,16 @@ assert d.gc == 1
# 4 gc [4]
# 5 nil
# 6 __path__ [2]
# 7 a [3]
# 7 a [3]
import gc
gc.collect()
a = []
del a
assert gc.collect() == 1
a = []
a.append(a)
del a
assert gc.collect() == 1