From 0d5e3809b146b5cf624604595f5b0ebec5dfb469 Mon Sep 17 00:00:00 2001 From: Andrey Rahmatullin Date: Tue, 25 Oct 2022 15:30:25 +0500 Subject: [PATCH] Allow empty strings in asserts (#130) --- cssselect/xpath.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cssselect/xpath.py b/cssselect/xpath.py index 2d1ce37..f51cfb4 100644 --- a/cssselect/xpath.py +++ b/cssselect/xpath.py @@ -673,14 +673,14 @@ def xpath_attrib_exists(self, xpath: XPathExpr, name: str, value: Optional[str]) return xpath def xpath_attrib_equals(self, xpath: XPathExpr, name: str, value: Optional[str]) -> XPathExpr: - assert value + assert value is not None xpath.add_condition("%s = %s" % (name, self.xpath_literal(value))) return xpath def xpath_attrib_different( self, xpath: XPathExpr, name: str, value: Optional[str] ) -> XPathExpr: - assert value + assert value is not None # FIXME: this seems like a weird hack... if value: xpath.add_condition("not(%s) or %s != %s" % (name, name, self.xpath_literal(value))) @@ -703,7 +703,7 @@ def xpath_attrib_includes( def xpath_attrib_dashmatch( self, xpath: XPathExpr, name: str, value: Optional[str] ) -> XPathExpr: - assert value + assert value is not None # Weird, but true... xpath.add_condition( "%s and (%s = %s or starts-with(%s, %s))"