myvyang / pyv8

Automatically exported from code.google.com/p/pyv8
0 stars 0 forks source link

[demos/w3c.py] NavigableString error #98

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

A problem exists in demos/w3c.py as shown in the following output

buffer@alnitak ~/pyv8/demos $ python w3c.py 
........E..
======================================================================
ERROR: testDocument (__main__.HTMLDocumentTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "w3c.py", line 1485, in testDocument
    self.doc.title = "another title"
  File "/usr/lib64/python2.6/site-packages/PyV8-1.0-py2.6-linux-x86_64.egg/PyV8.py", line 123, in __setattr__
    return object.__setattr__(self, name, value)
  File "w3c.py", line 1072, in setter
    tag.string = tag.contents[0]
  File "/usr/lib64/python2.6/site-packages/BeautifulSoup.py", line 559, in setString
    self.clear()
  File "/usr/lib64/python2.6/site-packages/BeautifulSoup.py", line 587, in clear
    child.extract()
  File "/usr/lib64/python2.6/site-packages/BeautifulSoup.py", line 155, in extract
    if self.parent:
  File "/usr/lib64/python2.6/site-packages/BeautifulSoup.py", line 448, in __getattr__
    raise AttributeError, "'%s' object has no attribute '%s'" % (self.__class__.__name__, attr)
AttributeError: 'NavigableString' object has no attribute 'parent'

----------------------------------------------------------------------
Ran 11 tests in 0.035s

FAILED (errors=1)

The problem seems related to BeautifulSoup NavigableString implementation which 
does not call PageElement `setup' method. By the way trying to modify the 
w3c.py code in order to do it after instantiating the NavigableString object 
was not effective.

Original issue reported on code.google.com by angelo.d...@gmail.com on 4 Aug 2011 at 10:37

GoogleCodeExporter commented 9 years ago
It caused by BeautifulSoup 3.2.0, it use different structure with BeautifulSoup 
3.1.x which was used to create the demo.

Original comment by flier...@gmail.com on 10 Aug 2011 at 3:48

GoogleCodeExporter commented 9 years ago
add BeautifulSoup 3.1.0.1 for the demo after SVN code r388

http://www.crummy.com/software/BeautifulSoup/download/3.1.x/BeautifulSoup-3.1.0.
1.tar.gz

Original comment by flier...@gmail.com on 10 Aug 2011 at 4:03