.replaceWith(PyQuery element) raises error #9

gawel opened this Issue Nov 28, 2012 · 2 comments


None yet
3 participants

gawel commented Nov 28, 2012

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/pyquery.py", line 1174, in replaceWith
    value(i, element) + (element.tail or ''))
  File "/usr/local/lib/python2.7/dist-packages/pyquery/pyquery.py", line 247, in __call__
    result = self.__class__(*args, parent=self, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pyquery/pyquery.py", line 221, in __init__
    xpath = self._css_to_xpath(selector)
  File "/usr/local/lib/python2.7/dist-packages/pyquery/pyquery.py", line 232, in _css_to_xpath
    selector = selector.replace('[@', '[')
AttributeError: 'int' object has no attribute 'replace'

karolyi commented Mar 2, 2013

+1 to that.

jzelez commented Mar 17, 2013


gawel added a commit that referenced this issue Jan 3, 2014

@gawel gawel closed this Jan 3, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment