From fe1dff01917f4f533e2e66de86dd375688fdfffe Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 23 Sep 2024 19:10:32 +0500 Subject: [PATCH] ifcopenshell.stream - fix garbage collection errors Mentioined in #5457 Errors such as: Exception ignored in: Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/ifcopenshell/file.py", line 284, in __del__ del file_dict[self.file_pointer()] ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/ifcopenshell/file.py", line 444, in __getattr__ return getattr(self.wrapped_data, attr) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'file_pointer' --- src/ifcopenshell-python/ifcopenshell/stream.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ifcopenshell-python/ifcopenshell/stream.py b/src/ifcopenshell-python/ifcopenshell/stream.py index 79d13a6e04..f6598624f8 100644 --- a/src/ifcopenshell-python/ifcopenshell/stream.py +++ b/src/ifcopenshell-python/ifcopenshell/stream.py @@ -284,6 +284,10 @@ try: return True return False + def __del__(self) -> None: + # Override to avoid clean up unrelated to stream file. + pass + class stream_entity(entity_instance): def __init__(self, id: int, ifc_class: str, file: stream = None): if not ifc_class: