From e2a632dc72f6d93e0ef313e634a94ab6d37e18bb Mon Sep 17 00:00:00 2001 From: lightovernight Date: Fri, 7 Mar 2025 17:51:49 +0800 Subject: [PATCH] Improve Frame line number retrieval logic --- src/interpreter/frame.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/interpreter/frame.c b/src/interpreter/frame.c index e8e3293b..6ba02eb6 100644 --- a/src/interpreter/frame.c +++ b/src/interpreter/frame.c @@ -121,8 +121,11 @@ void Frame__gc_mark(py_Frame* self) { int Frame__lineno(const py_Frame* self) { int ip = self->ip; - if(ip < 0) return 0; - return c11__getitem(BytecodeEx, &self->co->codes_ex, ip).lineno; + if(ip >= 0) + return c11__getitem(BytecodeEx, &self->co->codes_ex, ip).lineno; + if(!self->is_locals_special) + return self->co->start_line; + return 0; } int Frame__iblock(const py_Frame* self) {