jjlee / mechanize

Stateful programmatic web browsing in Python, after Andy Lester's Perl module WWW::Mechanize .
http://wwwsearch.sourceforge.net/mechanize/
618 stars 121 forks source link

Cannot read form with SubmitControl that is disabled and has no value #57

Open abielr opened 12 years ago

abielr commented 12 years ago

Mechanize crashes when attempting to select a form that includes a SubmitControl that is disabled and has no value. When initializing a SubmitControl with no value, mechanize will attempt to set its value to an empty string; however, since the control is disabled, this will raise an AttributeError. I've encountered this situation on a page that has a disabled image control (ImageControl inherits from SubmitControl).

Here is an example form that will raise the error when br.select_form() or br.forms() is called:

<form action="http://whatever" method="POST">
    <input name="test" type="submit" disabled="disabled" />
</form>