From 4b9220bcbfea2c43aa0e7a76402ccdeff591a092 Mon Sep 17 00:00:00 2001 From: mozman Date: Fri, 25 Oct 2024 13:12:22 +0200 Subject: [PATCH] fix query string creation --- src/ezdxf/sections/blocks.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ezdxf/sections/blocks.py b/src/ezdxf/sections/blocks.py index 6cc4e4d34..23f6ff877 100644 --- a/src/ezdxf/sections/blocks.py +++ b/src/ezdxf/sections/blocks.py @@ -10,7 +10,7 @@ Optional, ) import logging - +from pyparsing import ParseException from ezdxf.audit import Auditor, AuditError from ezdxf.layouts.blocklayout import BlockLayout from ezdxf.lldxf import const, validator @@ -415,7 +415,13 @@ def delete_block(self, name: str, safe: bool = True) -> None: raise DXFBlockInUseError( f'Special block "{name}" maybe used without explicit INSERT entity.' ) - block_refs = self.doc.query(f"INSERT[name=='{name}']i") # ignore case + query_string = f'INSERT[name=="{name}"]i' + try: + block_refs = self.doc.query(query_string) # ignore case + except ParseException: + logger.error(f'Parsing error in query string: "{query_string}"') + return + if len(block_refs): raise DXFBlockInUseError(f'Block "{name}" is still in use.') self.__delitem__(name)