summaryrefslogtreecommitdiff
path: root/bs4/element.py
diff options
context:
space:
mode:
authorEric Wieser <>2015-08-06 00:49:58 +0100
committerEric Wieser <>2015-08-06 00:49:58 +0100
commit70a1b795bc1b0b03e71539b4fb18813baf0efa75 (patch)
tree8ee7238f0fec61e54447a1a203e8745fee1ad323 /bs4/element.py
parent0d5e476b466abb48766c48693d7b37ce570d9d1b (diff)
Use identity comparisons for tree traversal
Otherwise, different NavigableStrings compare equal. Fixes Bug #1481520
Diffstat (limited to 'bs4/element.py')
-rw-r--r--bs4/element.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/bs4/element.py b/bs4/element.py
index c70ad5a..60464b6 100644
--- a/bs4/element.py
+++ b/bs4/element.py
@@ -262,19 +262,19 @@ class PageElement(object):
next_element = last_child.next_element
if (self.previous_element is not None and
- self.previous_element != next_element):
+ self.previous_element is not next_element):
self.previous_element.next_element = next_element
- if next_element is not None and next_element != self.previous_element:
+ if next_element is not None and next_element is not self.previous_element:
next_element.previous_element = self.previous_element
self.previous_element = None
last_child.next_element = None
self.parent = None
if (self.previous_sibling is not None
- and self.previous_sibling != self.next_sibling):
+ and self.previous_sibling is not self.next_sibling):
self.previous_sibling.next_sibling = self.next_sibling
if (self.next_sibling is not None
- and self.next_sibling != self.previous_sibling):
+ and self.next_sibling is not self.previous_sibling):
self.next_sibling.previous_sibling = self.previous_sibling
self.previous_sibling = self.next_sibling = None
return self
@@ -287,7 +287,7 @@ class PageElement(object):
last_child = self
while isinstance(last_child, Tag) and last_child.contents:
last_child = last_child.contents[-1]
- if not accept_self and last_child == self:
+ if not accept_self and last_child is self:
last_child = None
return last_child
# BS3: Not part of the API!