ThreadSafeForwardingResult checks for empty tags incorrectly

Bug #980263 reported by Benji York
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
testtools
Fix Released
Medium
Jonathan Lange

Bug Description

The ThreadSafeForwardingResult class in testtools has a helper method that checks whether or not a (new, gone) tuple of tags represents a non-empty set of tags. It is defined thusly:

    def _not_empty_tags(self, tags):
        return bool(tags[0] and tags[1])

As far as Gary and I can see, the above should be defined as

    def _not_empty_tags(self, tags):
        return bool(tags[0] or tags[1])

Or, a slight optimization:

    def _not_empty_tags(self, tags):
        return bool(tags[0] - tags[1])

Related branches

Revision history for this message
Jonathan Lange (jml) wrote :

What's the actual problem caused by this incorrectness?

Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 980263] Re: ThreadSafeForwardingResult checks for empty tags incorrectly

That is indeed wrong, but set differencing wouldn't be right either -
if you assume that the sets are disjoint (they always should be) then
a logical or is correct. A set difference would return empty if for
some reason the tags are not disjoint.
>>> set([1]) - set([1])
set([])

Jonathan Lange (jml)
Changed in testtools:
status: New → Triaged
importance: Undecided → Medium
assignee: nobody → Jonathan Lange (jml)
Jonathan Lange (jml)
Changed in testtools:
status: Triaged → In Progress
Jonathan Lange (jml)
Changed in testtools:
status: In Progress → Fix Committed
milestone: none → next
Jonathan Lange (jml)
Changed in testtools:
status: Fix Committed → 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.