Page MenuHomeSoftware Heritage

SortedList: Don't inherit from UserList.
ClosedPublic

Authored by vlorentz on Sep 29 2020, 7:24 PM.

Details

Summary

A class should only inherit from UserList if the type of data it presents is
the same as the data in the 'data' attribute, which isn't true here.

This means, for example, that SortedList.contains checked if the value
is in self.data, which always returns False (unless unlucky, but then it
returns True while it shouldn't).

By removing this inheritance, methods that are no longer implemented no longer
default to a buggy implementation.

Diff Detail

Event Timeline

Build is green

Patch application report for D4087 (id=14420)

Rebasing onto d46d4c7ac5...

Current branch diff-target is up to date.
Changes applied before test
commit 98369afd1015908bc21d4ebe14ac2e8a2d57a13e
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Sep 29 19:24:17 2020 +0200

    SortedList: Don't inherit from UserList.
    
    A class should only inherit from UserList if the type of data it presents is
    the same as the data in the 'data' attribute, which isn't true here.
    
    This means, for example, that SortedList.__contains__ checked if the value
    is in self.data, which always returns False (unless unlucky, but then it
    returns True while it shouldn't).
    
    By removing this inheritance, methods that are no longer implemented no longer
    default to a buggy implementation.

See https://jenkins.softwareheritage.org/job/DCORE/job/tests-on-diff/86/ for more details.

This revision is now accepted and ready to land.Sep 30 2020, 8:53 AM

Build is green

Patch application report for D4087 (id=14464)

Rebasing onto d46d4c7ac5...

Current branch diff-target is up to date.
Changes applied before test
commit d230cb3df3a363ab89390062027e6b55d008433a
Author: Valentin Lorentz <vlorentz@softwareheritage.org>
Date:   Tue Sep 29 19:24:17 2020 +0200

    SortedList: Don't inherit from UserList.
    
    A class should only inherit from UserList if the type of data it presents is
    the same as the data in the 'data' attribute, which isn't true here.
    
    This means, for example, that SortedList.__contains__ checked if the value
    is in self.data, which always returns False (unless unlucky, but then it
    returns True while it shouldn't).
    
    By removing this inheritance, methods that are no longer implemented no longer
    default to a buggy implementation.

See https://jenkins.softwareheritage.org/job/DCORE/job/tests-on-diff/87/ for more details.