Html parser's find_all does not work well with <input> elements

Bug #1681015 reported by Matt C
This bug report is a duplicate of:  Bug #1676935: Reading <br> tags differs per parser. Edit Remove
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Beautiful Soup
New
Undecided
Unassigned

Bug Description

http://stackoverflow.com/questions/43286551/python-beautifulsoup-returning-wrong-list-of-inputs-from-find-all

I have Python 2.7.3 and bs.version is 4.4.1

For some reason this code

from bs4 import BeautifulSoup # parsing

html = """
<html>
<head id="Head1"><title>Title</title></head>
<body>
    <form id="form" action="login.php" method="post">
        <input type="text" name="fname">
        <input type="text" name="email" >
        <input type="button" name="Submit" value="submit">
    </form>
</body>

</html>
"""

html_proc = BeautifulSoup(html, 'html.parser')

for form in html_proc.find_all('form'):
    for input in form.find_all('input'):
        print "input:" + str(input)

returns a wrong list of inputs:

input:<input name="fname" type="text">
<input name="email" type="text">
<input name="Submit" type="button" value="submit">
</input></input></input>
input:<input name="email" type="text">
<input name="Submit" type="button" value="submit">
</input></input>
input:<input name="Submit" type="button" value="submit">
</input>

It's supposed to return

input: <input name="fname" type="text">
input: <input type="text" name="email">
input: <input type="button" name="Submit" value="submit">

What happened?

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.