From 4e502b398eddc677567538d5356a855137e155f7 Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Tue, 7 Feb 2012 13:37:26 -0500 Subject: It's OK for a tag to contain another, identical tag, just not for it to contain itself. --- TODO | 3 --- bs4/element.py | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/TODO b/TODO index 564659c..e0e4927 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,3 @@ -html5lib frequently raises the "cannot insert a tag into itself" -error, which makes me think there's a bug in the treebuilder. - Tag.insert_before() and Tag.insert_after() Also, I think you can avoid the variable altogether by having repr diff --git a/bs4/element.py b/bs4/element.py index 211621e..8451d7c 100644 --- a/bs4/element.py +++ b/bs4/element.py @@ -109,7 +109,7 @@ class PageElement(object): _lastRecursiveChild = _last_descendant def insert(self, position, new_child): - if new_child == self: + if new_child is self: raise ValueError("Cannot insert a tag into itself.") if (isinstance(new_child, basestring) and not isinstance(new_child, NavigableString)): -- cgit v1.2.3