From 634ad16d4571c9999d8f29d00a6c51cfb04d4a0d Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sat, 4 May 2024 16:53:36 +0800 Subject: [PATCH] some fix --- include/pocketpy/bindings.h | 1 + src/vm.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/include/pocketpy/bindings.h b/include/pocketpy/bindings.h index 46aca56a..3a3d7aba 100644 --- a/include/pocketpy/bindings.h +++ b/include/pocketpy/bindings.h @@ -89,6 +89,7 @@ PyObject* VM::bind(PyObject* obj, const char* sig, const char* docstring, Ret(T: template PyObject* VM::bind_field(PyObject* obj, const char* name, F T::*field){ static_assert(!std::is_reference_v); + PK_ASSERT(is_type(obj, tp_type)); std::string_view name_sv(name); int pos = name_sv.find(':'); if(pos > 0) name_sv = name_sv.substr(0, pos); auto fget = [](VM* vm, ArgsView args) -> PyObject*{ diff --git a/src/vm.cpp b/src/vm.cpp index 42439e27..5d5b1b20 100644 --- a/src/vm.cpp +++ b/src/vm.cpp @@ -1269,6 +1269,7 @@ PyObject* VM::bind(PyObject* obj, const char* sig, const char* docstring, Native } PyObject* VM::bind_property(PyObject* obj, const char* name, NativeFuncC fget, NativeFuncC fset){ + PK_ASSERT(is_type(obj, tp_type)); std::string_view name_sv(name); int pos = name_sv.find(':'); if(pos > 0) name_sv = name_sv.substr(0, pos); PyObject* _0 = heap.gcnew(tp_native_func, fget, 1, false);