From 8f48c7d0817339e86b06c65febf99c62f92bf490 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sat, 14 Jun 2025 18:12:53 +0800 Subject: [PATCH] Update internal.c --- src/public/internal.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/public/internal.c b/src/public/internal.c index d27e6db7..2ef00862 100644 --- a/src/public/internal.c +++ b/src/public/internal.c @@ -9,11 +9,15 @@ _Thread_local VM* pk_current_vm; static bool pk_initialized; +static bool pk_finalized; + static VM pk_default_vm; static VM* pk_all_vm[16]; static py_TValue _True, _False, _None, _NIL; void py_initialize() { + c11__rtassert(!pk_finalized); + if(pk_initialized) { // c11__abort("py_initialize() can only be called once!"); return; @@ -52,6 +56,9 @@ py_GlobalRef py_None() { return &_None; } py_GlobalRef py_NIL() { return &_NIL; } void py_finalize() { + if(pk_finalized) c11__abort("py_finalize() can only be called once!"); + pk_finalized = true; + for(int i = 1; i < 16; i++) { VM* vm = pk_all_vm[i]; if(vm) {