[Git][security-tracker-team/security-tracker][master] 5 commits: lib/python/bugs.py: delete PackageNoteFromDB

Emilio Pozuelo Monfort (@pochu) pochu at debian.org
Tue Aug 18 12:45:00 BST 2026



Emilio Pozuelo Monfort pushed to branch master at Debian Security Tracker / security-tracker


Commits:
647d0655 by Helmut Grohne at 2026-08-18T12:57:24+02:00
lib/python/bugs.py: delete PackageNoteFromDB

This class was never used and it also does not work as it calls
PackageNote.__init__ and passes a "package" where "self" is expected.
Evidently this is dead code and can be deleted.

- - - - -
02e0e308 by Helmut Grohne at 2026-08-18T12:57:24+02:00
lib: delete mergeAsSets

This function only has one use. Given that Python now has builtin
support for sets, writing it is simpler than calling it. Get rid of the
helper entirely.

- - - - -
75e38955 by Helmut Grohne at 2026-08-18T12:57:24+02:00
lib/python/debian_support.py: better __eq__ implementation

Python allows comparing objects of different type for equality. Hence,
__eq__ should be supporting that. When things are not equal, we may
delegate to the reverse operator by returning NotImplemented. This is a
rare corner case not exercised in practice, but correctly implementing
it makes type checking easier.

- - - - -
2eefb9a3 by Helmut Grohne at 2026-08-18T12:57:24+02:00
lib/python/debian_support.py: drop more Py2.x support

- - - - -
371abe0f by Emilio Pozuelo Monfort at 2026-08-18T11:44:57+00:00
Merge branch 'helmutg/cleanup' into 'master'

lib/python: minor cleanups

See merge request security-tracker-team/security-tracker!321
- - - - -


2 changed files:

- lib/python/bugs.py
- lib/python/debian_support.py


Changes:

=====================================
lib/python/bugs.py
=====================================
@@ -107,27 +107,13 @@ class PackageNote:
         """Add the contents of another, compatible package note to this one."""
         assert self.release is other.release
         assert self.package == other.package
-        self.bugs = debian_support.mergeAsSets(self.bugs, other.bugs)
+        self.bugs = sorted(set(self.bugs).union(other.bugs))
         self.urgency = max(self.urgency, other.urgency)
         if self.fixed_version is None or other.fixed_version is None:
             self.fixed_version = None
         else:
             self.fixed_version = max(self.fixed_version, other.fixed_version)
 
-class PackageNoteFromDB(PackageNote):
-    def __init__(self, cursor, nid):
-        for (bug_name, package, fixed_version, release, urgency,
-             package_kind, bug_origin) in cursor.execute\
-            ("""SELECT bug_name, package, fixed_version, release, urgency,
-            package_kind, bug_origin
-            FROM package_notes WHERE id = ?""", (nid,)):
-            PackageNote.__init__(package, fixed_version, release, urgency)
-            self.id = nid
-            self.bug_name = bug_name
-            self.package_kind = package_kind
-            self.loadBugs(cursor)
-            return
-        raise ValueError("invalid package note ID %d" % id)
 
 class PackageNoteParsed(PackageNote):
     """Subclass with a constructor that parses package notes."""


=====================================
lib/python/debian_support.py
=====================================
@@ -99,7 +99,9 @@ class Version:
         return self.__cmp__(other) <=  0
 
     def __eq__(self, other):
-        return self.__cmp__(other) ==  0
+        if isinstance(other, Version):
+            return self.__cmp__(other) ==  0
+        return NotImplemented
 
     def __gt__(self, other):
         return self.__cmp__(other) >  0
@@ -201,8 +203,12 @@ class PseudoEnum:
         return self._order < other._order
     def __le__(self, other):
         return self._order <= other._order
+
     def __eq__(self, other):
-        return self._order == other._order
+        if isinstance(other, PseudoEnum):
+            return self._order == other._order
+        return NotImplemented
+
     def __gt__(self, other):
         return self._order > other._order
     def __ge__(self, other):
@@ -227,9 +233,7 @@ del listReleases
 def readLinesSHA1(lines):
     m = sha1()
     for l in lines:
-        if sys.version_info.major == 3:
-            l = l.encode('utf-8')
-        m.update(l)
+        m.update(l.encode('utf-8'))
     return m.hexdigest()
 
 def patchesFromEdScript(source,
@@ -441,16 +445,6 @@ def updateFile(remote, local, verbose=None):
     replaceFile(lines, local)
     return lines
 
-def mergeAsSets(*args):
-    """Create an order set (represented as a list) of the objects in
-    the sequences passed as arguments."""
-    s = {}
-    for x in args:
-        for y in x:
-            s[y] = True
-    l = list(s.keys())
-    l.sort()
-    return l
 
 class BinaryPackage(object):
     __slots__ = ("name", "version", "arch", "source", "source_version")
@@ -651,9 +645,6 @@ def test():
     patchLines(file_a, patchesFromEdScript(patch))
     assert ''.join(file_b) == ''.join(file_a)
 
-    assert len(mergeAsSets([])) == 0
-    assert ''.join(mergeAsSets("abc", "cb")) == "abc"
-
     assert repr(internRelease("sid")) == "Release('sid')"
 
 if __name__ == "__main__":



View it on GitLab: https://salsa.debian.org/security-tracker-team/security-tracker/-/compare/6340ad2ec384c12ac4438ed6a440be4ca4a272d6...371abe0f81b1bbbc7cb2464cd43257097bf3cfed

-- 
View it on GitLab: https://salsa.debian.org/security-tracker-team/security-tracker/-/compare/6340ad2ec384c12ac4438ed6a440be4ca4a272d6...371abe0f81b1bbbc7cb2464cd43257097bf3cfed
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-security-tracker-commits/attachments/20260818/db613ed0/attachment-0001.htm>


More information about the debian-security-tracker-commits mailing list