Can't insert an element before or after an identical element

Bug #1810692 reported by Leonard Richardson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Beautiful Soup
Fix Released
Undecided
Unassigned

Bug Description

This works in 4.6.3 but not in 4.7.0 (reported by Alex Krupp):

--

text = '<br>'
soup = BeautifulSoup(text, "lxml")

for br_tag in soup.find_all('br'):
  br_tag.insert_before(soup.new_tag('br'))

--

Isaac's comment:

The self check is definitely a bug. insert_before and insert_after can now take multiple arguments, and in the original proposal, we looped through the arguments checking if the tag to be inserted **is** self, the check was moved out of the loop (which makes sense) so we could do the check once, but it is now checking if self is **in** args which is doing check of **equality**, which we do not want to do.

Revision history for this message
Leonard Richardson (leonardr) wrote :

Fixed in revision 495.

Changed in beautifulsoup:
status: New → Fix Committed
Revision history for this message
Isaac Muse (facelessuser) wrote :

Oh, cool. I just created a branch. Didn't realize you fixed it.

Changed in beautifulsoup:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.