Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


.replaceWith(PyQuery element) raises error #9

gawel opened this Issue · 2 comments

3 participants


Anonymous created an issue 2012-09-07

Using .replaceWith(PyQuery element) raises an error. This is in pyquery-1.2.1 from PyPI.

from pyquery import PyQuery as pq
root = pq("""<root><child/></root>""")
replace = pq("""<replace/>""")
child = root.find('child')

# Raises
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pyquery/", line 1174, in replaceWith
    value(i, element) + (element.tail or ''))
  File "/usr/local/lib/python2.7/dist-packages/pyquery/", line 247, in __call__
    result = self.__class__(*args, parent=self, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pyquery/", line 221, in __init__
    xpath = self._css_to_xpath(selector)
  File "/usr/local/lib/python2.7/dist-packages/pyquery/", line 232, in _css_to_xpath
    selector = selector.replace('[@', '[')
AttributeError: 'int' object has no attribute 'replace'

+1 to that.



@gawel gawel referenced this issue from a commit
@gawel fixed issue #9 b81a9e8
@gawel gawel closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.