Skip to content

Commit e246287

Browse files
committed
Fix test failure due to errors raised in DPFVector
1 parent 1ac82c4 commit e246287

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/ansys/dpf/gate/dpf_vector.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ def has_changed(self):
9191
return self._modified and self.size > 0 # Updating is not necessary for an empty vector. Updating it can cause issue, see #2274
9292

9393
def __del__(self):
94-
try:
95-
self.dpf_vector_api.dpf_vector_delete(self)
96-
except Exception as e:
97-
raise e
94+
if hasattr(self, "_internal_obj"):
95+
try:
96+
self.dpf_vector_api.dpf_vector_delete(self)
97+
except Exception as e:
98+
raise e
9899

99100

100101
class DPFVectorInt(DPFVectorBase):
@@ -121,7 +122,7 @@ def commit(self) -> None:
121122

122123
def __del__(self):
123124
try:
124-
if self._array:
125+
if hasattr(self, "_array") and self._array:
125126
self.dpf_vector_api.dpf_vector_int_free(self, self.internal_data, self.internal_size,
126127
self.has_changed())
127128
except Exception as e:
@@ -153,7 +154,7 @@ def commit(self) -> None:
153154

154155
def __del__(self):
155156
try:
156-
if self._array:
157+
if hasattr(self, "_array") and self._array:
157158
self.dpf_vector_api.dpf_vector_double_free(self, self.internal_data, self.internal_size,
158159
self.has_changed())
159160
except Exception as e:

0 commit comments

Comments
 (0)