Issue #59 resolved

The `:contains()` selector is completely broken

Remigiusz Modrzejewski
created an issue

Today I tried to use an old script that used to work. Unfortunately, it breaks at any usage of the :contains() selector. A minified example:

import pyquery
query = pyquery.PyQuery('<html><p>foo</p></html>')
query('p:contains("foo")')


---------------------------------------------------------------------------
XPathEvalError                            Traceback (most recent call last)
<ipython-input-5-322269d1cc1f> in <module>()
----> 1 query('p:contains("foo")')

/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/pyquery/pyquery.pyc in __call__(self, *args, **kwargs)
    245            not args[0].startswith('<'):
    246             args += (self,)
--> 247         result = self.__class__(*args, parent=self, **kwargs)
    248         return result
    249

/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/pyquery/pyquery.pyc in __init__(self, *args, **kwargs)
    221                 xpath = self._css_to_xpath(selector)
    222                 results = [tag.xpath(xpath, namespaces=namespaces) \
--> 223                                                     for tag in elements]
    224                 # Flatten the results
    225                 elements = []

/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/lxml/etree.so in lxml.etree._Element.xpath (src/lxml/lxml.etree.c:45370)()

/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/lxml/etree.so in lxml.etree.XPathElementEvaluator.__call__ (src/lxml/lxml.etree.c:125700)()

/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/lxml/etree.so in lxml.etree._XPathEvaluatorBase._handle_result (src/lxml/lxml.etree.c:124824)()

/usr/local/Cellar/python/2.7.3/lib/python2.7/site-packages/lxml/etree.so in lxml.etree._XPathEvaluatorBase._raise_eval_error (src/lxml/lxml.etree.c:124693)()

XPathEvalError: Invalid expression

Comments (1)

  1. Log in to comment