Make lxml smart strings functionality customizable

This commit is contained in:
Paul Tremberth 2014-01-16 10:44:17 +01:00
parent 1f184ed7bf
commit 5eb336215c
1 changed files with 2 additions and 1 deletions

View File

@ -57,6 +57,7 @@ class Selector(object_ref):
# set:trailing
"set": "http://exslt.org/sets"
}
_lxml_smart_strings = False
def __init__(self, response=None, text=None, type=None, namespaces=None,
_root=None, _expr=None):
@ -86,7 +87,7 @@ class Selector(object_ref):
try:
result = xpathev(query, namespaces=self.namespaces,
smart_strings=False)
smart_strings=self._lxml_smart_strings)
except etree.XPathError:
raise ValueError("Invalid XPath: %s" % query)