From cd78fa1af1288c47c6d990a92b0d9373c7fb18c3 Mon Sep 17 00:00:00 2001 From: Juan Gomez Mosquera Date: Thu, 24 Oct 2024 20:20:29 -0400 Subject: [PATCH] Adding runtime typechecking to SharedMemory::_from_raw --- wasmtime/_sharedmemory.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wasmtime/_sharedmemory.py b/wasmtime/_sharedmemory.py index f04b772..23e06f8 100644 --- a/wasmtime/_sharedmemory.py +++ b/wasmtime/_sharedmemory.py @@ -21,6 +21,9 @@ def __init__(self, engine: Engine, ty: MemoryType): @classmethod def _from_raw(cls, sharedmemory: ffi.wasmtime_sharedmemory_t) -> "SharedMemory": + if not isinstance(sharedmemory, ffi.wasmtime_sharedmemory_t): + raise TypeError("wrong shared memory pointer type provided to _from_raw") + ty: "SharedMemory" = cls.__new__(cls) ty._set_ptr(sharedmemory) return ty