testbrowser gives unhelpful errors

Bug #98414 reported by Marius Gedminas
2
Affects Status Importance Assigned to Milestone
Zope 3
Won't Fix
Medium
Unassigned
zope.testbrowser
Invalid
Low
Unassigned

Bug Description

Every now and then when something goes wrong (server error), zope.testbrowser gives this confusing error message instead:

Failed example:
    browser.getLink('Some link').click()
Exception raised:
    Traceback (most recent call last):
      File ".../zope3/src/zope/testing/doctest.py", line 1361, in __run
        compileflags, 1) in test.globs
      File "<doctest demo.txt[11]>", line 1, in ?
        abrowser.getLink('Print Ads').click()
      File ".../zope3/src/zope/testbrowser/browser.py", line 388, in click
        self.browser.mech_browser.follow_link(self.mech_link)
      File ".../zope3/src/mechanize/_mechanize.py", line 448, in follow_link
        return self.open(self.click_link(link, **kwds))
      File ".../zope3/src/mechanize/_mechanize.py", line 177, in open
        return self._mech_open(url, data)
      File ".../zope3/src/mechanize/_mechanize.py", line 217, in _mech_open
        self.set_response(response)
      File ".../zope3/src/mechanize/_mechanize.py", line 255, in set_response
        response = upgrade_response(response)
      File ".../zope3/src/mechanize/_mechanize.py", line 84, in upgrade_response
        data = get_data()
      File ".../zope3/src/mechanize/_util.py", line 426, in get_data
        return self.read(-1)
      File ".../zope3/src/mechanize/_util.py", line 444, in read
        self.__cache.write(self.wrapped.read())
      File ".../zope3/src/mechanize/_util.py", line 444, in read
        self.__cache.write(self.wrapped.read())
    TypeError: 'NoneType' object is not callable

I think I saw this one reported a while ago, but I cannot find the issue in the collector.

Tags: bug community
Revision history for this message
Benji York (benji) wrote :

I've seen this before, and have a vague feeling that I fixed it (or at least looked at it).

What version(s) of testbrowser do you see this in? Can you demonstrate how to reproduce it?

Revision history for this message
Benji York (benji) wrote :

I've narrowed this down to either a bug in mechanize or urllib2. I've checked in a work around to the trunk and 3.3 branch (revisions 69378 and 69379).

The problem arrises when the attempt to open a URI as the result of a redirect fails (returns an error HTTP status code). The mechanize/urllib2 data structures are in an unanticipated state and an attempt to read from a closed request triggers an exception (the one noted below).

I'll try to put together a pure mechanize test case and see what they think about it (unless someone beats me to it; hint, hint).

Tres Seaver (tseaver)
Changed in zope.testbrowser:
importance: Undecided → Medium
Changed in zope3:
status: New → Won't Fix
Tres Seaver (tseaver)
Changed in zope.testbrowser:
assignee: nobody → Benji York (benji-york)
importance: Medium → Low
status: New → Triaged
Benji York (benji)
Changed in zope.testbrowser:
assignee: Benji York (benji) → nobody
Revision history for this message
Colin Watson (cjwatson) wrote :

The zope.testbrowser project on Launchpad has been archived at the request of the Zope developers (see https://answers.launchpad.net/launchpad/+question/683589 and https://answers.launchpad.net/launchpad/+question/685285). If this bug is still relevant, please refile it at https://github.com/zopefoundation/zope.testbrowser.

Changed in zope.testbrowser:
status: Triaged → Invalid
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.