Creation of weakref in Browser.__init__() increfs self with callback argument

Bug #646077 reported by Gavin Panella
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Triaged
Low
Unassigned

Bug Description

The following code in c.l.testing.browser.Browser.__init__() increases
the reference count to self by 1 because of the self._refclose
argument to weakref.ref():

  _live_browser_set.add(weakref.ref(self, self._refclose))

I don't think it matters too much because the browsers are cleaned up
in tearDown(), so this might not be worth fixing.

However, one possible fix might be to add the following function
(which might have to be global):

  def browser_closer(close):
      return lambda ref: close()

and change the creation of the weakref:

  _live_browser_set.add(
      weakref.ref(self, browser_closer(self.mech_browser.close)))

Revision history for this message
Gary Poster (gary) wrote :

It does sound like this is either over- or under-engineered. :-)

Changed in launchpad-foundations:
status: New → Triaged
importance: Undecided → Low
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.