Skip to content

Commit

Permalink
fix query string creation
Browse files Browse the repository at this point in the history
  • Loading branch information
mozman committed Oct 25, 2024
1 parent ca68779 commit 4b9220b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/ezdxf/sections/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4b9220b

Please sign in to comment.