Mechanize: __version__ = (0, 1, 8, "b", None) # 0.1.8b<br><br>Why does ClientForm.py return instead of closing the option and select tag when self._current_form == self._global_form?<br><br>ClientForm.py:<br> def end_select(self):<br>
debug("")<br> if self._current_form is self._global_form:<br> return<br> if self._option is not None:<br> self._end_option()<br> self._select = None<br><br>When there is more than one select statement outside of a form (legal html), ClientForm (improperly) raises the nested SELECTs error because the first select is never closed. This is due to the fact that during __init__ of _AbstractFormParser, self._current_form = self._global_form = self.forms[0]. When end_select is called, self._current_form == self._global_form because there are no forms. We return instead of closing the option tag and the select tag. This is a regression from __version__ = (0, 0, 12, "a", None) # 0.0.12a. <br>
<br>Under what circumstances would we want to return instead of closing the tag?<br><br>The parser works correctly if end_select is changed to:<br>ClientForm.py:<br>
def end_select(self):<br>
debug("")<br> if self._option is not None:<br>
self._end_option()<br>
self._select = None<br><br><br><br>Example form:<br>NOTE: This form contains valid html however upon parse, nested SELECTs error is raised.<br><html> <br>
<body> <br> <select name="b" id="3"> <option class="select" value="2">XML format</option> <br>
<option class="select" value="1">CSV format</option> <br> </select> <br>
<select name="e" id="5"> <br> <option class="select" value="2">XML format</option> <option class="select" value="1">CSV format</option> <br>
</select> <br>
</body> <br></html> <br><br>-DaveO<br>
<br><br>