Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

.replaceWith(PyQuery element) raises error #9

Closed
gawel opened this Issue · 2 comments

3 participants

@gawel
Owner

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')
child.replaceWith(replace)

# 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

+1 to that.

@jzelez

+1

@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.