python-mechanize doesn't work in python2.6

Bug #337918 reported by Elliot Murphy
4
Affects Status Importance Assigned to Milestone
Ubuntu One Servers
Fix Released
Undecided
Unassigned
python-mechanize (Ubuntu)
Fix Released
High
Ken VanDine

Bug Description

Binary package hint: python-mechanize

This is different from the very-recently-fixed bug about mechanize not being able to be imported under python2.6

I'm running on jaunty, with:
python-mechanize:
  Installed: 0.1.7b-3ubuntu1
python2.6:
  Installed: 2.6.1-1ubuntu1

Here is an example showing how mechanize doesn't work:

Python 2.6.1+ (r261:67515, Mar 2 2009, 13:10:18)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from mechanize import Browser
/usr/lib/python2.6/dist-packages/mechanize/_auth.py:14: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import re, base64, urlparse, posixpath, md5, sha, sys, copy
/usr/lib/python2.6/dist-packages/mechanize/_auth.py:14: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
  import re, base64, urlparse, posixpath, md5, sha, sys, copy
>>> b = Browser()
>>> b.open('http://example.com')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/dist-packages/mechanize/_mechanize.py", line 203, in open
    return self._mech_open(url, data)
  File "/usr/lib/python2.6/dist-packages/mechanize/_mechanize.py", line 229, in _mech_open
    response = UserAgentBase.open(self, request, data)
  File "/usr/lib/python2.6/dist-packages/mechanize/_opener.py", line 175, in open
    req = meth(req)
  File "/usr/lib/python2.6/dist-packages/mechanize/_http.py", line 440, in http_request
    self.rfp.read()
  File "/usr/lib/python2.6/dist-packages/mechanize/_http.py", line 387, in read
    robotparser._debug("parse lines")
AttributeError: 'module' object has no attribute '_debug'

In some more involved code, I'm also hitting problems with missing timeout attributes, and this issue is described as fixed in the 0.1.10 changelog for mechanize:

2008-12-03 John J Lee <email address hidden>
 * 0.1.10 release.
 * Add support for Python 2.6: Raise URLError on file: URL errors,
   not IOError (port of upstream urllib2 fix). Add support for
   Python 2.6's per-connection timeouts: Add timeout arguments to
   urlopen(), Request constructor, .open(), and .open_novisit().

(from http://wwwsearch.sourceforge.net/mechanize/src/ChangeLog.txt).

It seems like the best course of action here is to update to the newer 0.1.11 release of python-mechanize, rather than to try picking out all the python2.6 compatibility fixes and apply them to the old release. mechanize 0.1.7b is from mid 2007, it's pretty old.

Revision history for this message
Elliot Murphy (statik) wrote :

ken mentioned on IRC he would be willing to prepare a new package and propose it, I guess it would also need to go through the process for a version freeze exception?

Changed in python-mechanize:
assignee: nobody → ken-vandine
Changed in python-mechanize:
status: New → In Progress
Revision history for this message
Martin Pitt (pitti) wrote :

There is no such thing like a "version freeze", but we have feature freeze. Please provide an upstream changelog (URL is sufficient), and check whether the new upstream version introduces any new features, or just bugs. If there are new features, please subscribe ubuntu-release.

Either way, of course we should fix that, so please prepare a new package for testing. Thanks!

Changed in python-mechanize:
importance: Undecided → High
Revision history for this message
Martin Pitt (pitti) wrote :

http://wwwsearch.sourceforge.net/mechanize/src/ChangeLog.txt (from 1.8 on)

These look okay, mostly bug fixes and a few new functions, plus Python 2.6 compatibility. FF granted.

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Attached diff

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Updated diff, removed build req

Revision history for this message
Martin Pitt (pitti) wrote :

Thanks, Ken; I'll do some cleanup:

 - You changed pycentral to pysupport; we shouldn't do that, pycentral is generally better supported.
 - Your diff.gz has the inverse "gopher removal" patch applied; gopher doesn't work any more

Revision history for this message
Martin Pitt (pitti) wrote :

OK, I give up; pycentral just doesn't want to understand "2.5 or later", so I'll apply your move to pysupport.

Revision history for this message
Martin Pitt (pitti) wrote :

Ah, "XS-Python-Version: >= 2.5" is the secret sauce. I'll keep python-central then.

Revision history for this message
Launchpad Janitor (janitor) wrote :
Download full text (4.1 KiB)

This bug was fixed in the package python-mechanize - 0.1.11-0ubuntu1

---------------
python-mechanize (0.1.11-0ubuntu1) jaunty; urgency=low

  [ Ken VanDine ]
  * New upstream release (LP: #337918)
    - Fix quadratic performance in number of .read() calls (and add an
      automated performance test).
    - Add support for Python 2.6: Raise URLError on file: URL errors,
      not IOError (port of upstream urllib2 fix). Add support for
      Python 2.6's per-connection timeouts: Add timeout arguments to
      urlopen(), Request constructor, .open(), and .open_novisit().
    - Drop support for Python 2.3
    - Add Content-length header to Request object (httplib bug that
      prevented doing that was fixed in Python 2.4). There's no
      change is what is actually sent over the wire here, just in what
      headers get added to the Request object.
    - Fix AttributeError on .retrieve() with a Request (as opposed to
      URL string) argument
    - Don't change CookieJar state in .make_cookies().
    - Fix AttributeError in case where .make_cookies() or
      .cookies_for_request() is called before other methods like
      .extract_cookies() or .make_cookie_header()
    - Fixes affecting version cookie-attribute
      (http://bugs.python.org/issue3924).
    - Silence module logging's "no handlers could be found for logger
      mechanize" warning in a way that doesn't clobber attempts to set
      log level sometimes
    - Don't use private attribute of request in request upgrade
      handler (what was I thinking??)
    - Don't call setup() on import of setup.py
    - Add new public function effective_request_host
    - Add .get_policy() method to CookieJar
    - Add method CookieJar.cookies_for_request()
    - Fix documented interface required of requests and responses (and
      add some tests for this!)
    - Allow either .is_unverifiable() or .unverifiable on request
      objects (preferring the former)
    - Note that there's a new functional test for digest auth, which
      fails when run against the sourceforge site (which is the
      default). It looks like this reflects the fact that digest auth
      has been fairly broken since it was introduced in urllib2. I
      don't plan to fix this myself.
    - Fix ImportError if sqlite3 not available
    - Fix a couple of functional tests not to wait 5 seconds each
    - Close sockets. This only affects Python 2.5 (and later) -
      earlier versions of Python were unaffected. See
      http://bugs.python.org/issue1627441
    - Make title parsing follow Firefox behaviour wrt child
      elements (previously the behaviour differed between Factory and
      RobustFactory).
    - Fix BeautifulSoup RobustLinksFactory (hence RobustFactory) link
      text parsing for case of link text containing tags (Titus Brown)
    - Fix issue where more tags after <title> caused default parser to
      raise an exception
    - Handle missing cookie max-age value. Previously, a warning was
      emitted in this case.
    - Fix thoroughly broken digest auth (still need functional
      test!) (trebor74hr@...)
    - Handle cookies containing embedded tabs in mozilla format files
    - Remove an ass...

Read more...

Changed in python-mechanize:
status: In Progress → Fix Released
Revision history for this message
Elliot Murphy (statik) wrote :

works great as of this morning, thanks ken and pitti!

Changed in ubunet:
status: New → 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.