This error in ssl.math_hostname is displayed in version 2.7.9 (it is not in 2.7.5) and is related not to remove the host name from the hostname: port syntax. The following ssl.match_hostname entry fixes the error. Put this in front of your mechanization code:
import functools, re, urlparse import ssl old_match_hostname = ssl.match_hostname @functools.wraps(old_match_hostname) def match_hostname_bugfix_ssl_py_2_7_9(cert, hostname): m = re.search(r':\d+$',hostname)
Now the following mechanization code should work:
import mechanize import cookielib br = mechanize.Browser()
source share