From 53ec9b04748bd1e7d9e7faeb7a6e3cbbd8498059 Mon Sep 17 00:00:00 2001 From: _ <_> Date: Thu, 17 May 2018 11:35:43 -0700 Subject: [PATCH] Added exceptions for textures objects --- bindings/py3devil1tex.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/bindings/py3devil1tex.py b/bindings/py3devil1tex.py index 32aeb7f..6300ed1 100644 --- a/bindings/py3devil1tex.py +++ b/bindings/py3devil1tex.py @@ -82,7 +82,8 @@ del libc class pyTexturePack: def __init__(self, filedata): self.cstruct = ctypes.pointer(TexturePack()) - devil1tex.getheader(ctypes.byref(self.cstruct), filedata) + if not devil1tex.getheader(ctypes.byref(self.cstruct), filedata): + raise RuntimeError("failed to get texture pack header") return def show(self): @@ -99,7 +100,12 @@ class pyTextureBatchDescriptor: self.cstruct = ctypes.pointer(TextureBatchDescriptor()) ptrofptr = ctypes.byref(self.cstruct) if filedata: - devil1tex.getbatchdesc(ptrofptr, i, filedata, len(filedata)) + if not devil1tex.getbatchdesc( + ptrofptr, + i, + filedata, + len(filedata)): + raise RuntimeError("failed to get texturebatchdescriptor #" + str(i)) return def show(self): @@ -128,7 +134,12 @@ class pyTextureBatch: self.cstruct.batch = ctypes.cast( ctypes.create_string_buffer(memsize), ctypes.POINTER(Texture)) - devil1tex.gettextures(self.cstruct.batch, i, filedata, len(filedata)) + if not devil1tex.gettextures( + self.cstruct.batch, + i, + filedata, + len(filedata)): + raise RuntimeError("failed to get textures of batch #" + str(i)) return def gettextures(self):