diff options
author | Emilio Pozuelo Monfort <pochu@debian.org> | 2020-07-16 13:16:14 +0200 |
---|---|---|
committer | Emilio Pozuelo Monfort <pochu@debian.org> | 2020-07-29 10:20:33 +0200 |
commit | 37e775cc5d145a4e5c573278c694a098b6c10066 (patch) | |
tree | 8fcba54391f63a94754cda64eeec6c598548e662 /lib/python/bugs.py | |
parent | 98dbd1d464037d7e15773c28ec93075d75213be2 (diff) |
lib/python: use isinstance rather than types
types.TypeFoo are gone in python3.
Diffstat (limited to 'lib/python/bugs.py')
-rw-r--r-- | lib/python/bugs.py | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/python/bugs.py b/lib/python/bugs.py index 0c94d4aff3..f0ef8c9ab7 100644 --- a/lib/python/bugs.py +++ b/lib/python/bugs.py @@ -19,9 +19,10 @@ import debian_support import functools import os import re -import types import hashlib +from helpers import isstring + class Urgency(debian_support.PseudoEnum): pass def listUrgencies(): @@ -55,20 +56,19 @@ class PackageNote: def __init__(self, package, fixed_version, release, urgency): self.id = None self.package = package - if (fixed_version is not None - and type(fixed_version) in types.StringTypes): + if (isstring(fixed_version)): self.fixed_version = debian_support.Version(fixed_version) else: self.fixed_version = fixed_version if release == '': self.release = None else: - if type(release) == types.StringType: + if isstring(release): release = debian_support.internRelease(release) if release is None: raise ValueError("invalid release") self.release = release - if type(urgency) == types.StringType: + if isstring(urgency): urgency = internUrgency(urgency) if urgency is None: raise ValueError("invalid urgency") @@ -166,13 +166,13 @@ class PackageNoteParsed(PackageNote): class PackageNoteNoDSA: def __init__(self, package, release, comment, reason=None): - assert type(package) == types.StringType and package != '' - assert type(release) == types.StringType and release != '' - assert type(comment) == types.StringType + assert isstring(package) and package != '' + assert isstring(release) and release != '' + assert isstring(comment) if not reason: reason = '' else: - assert type(reason) == types.StringType + assert isstring(reason) self.package = package self.release = release self.comment = comment @@ -191,7 +191,7 @@ class BugBase: re_cve_name = re.compile(r'^CVE-\d{4}-\d{4,}$') def __init__(self, fname, lineno, date, name, description, comments): - assert type(fname) in types.StringTypes + assert isstring(fname) lineno = to_integer(lineno) self.source_file = fname self.source_line = lineno @@ -266,8 +266,8 @@ class Bug(BugBase): for n in notes: assert isinstance(n, PackageNote) \ or isinstance(n, PackageNoteNoDSA) - assert len(xref) == 0 or type(xref[0]) == types.StringType - assert type(not_for_us) == types.BooleanType + assert len(xref) == 0 or isstring(xref[0]) + assert isinstance(not_for_us, bool) BugBase.__init__(self, fname, lineno, date, name, description, comments) self.notes = notes @@ -307,7 +307,7 @@ class Bug(BugBase): class BugFromDB(Bug): def __init__(self, cursor, name): - assert type(name) in types.StringTypes + assert isstring(name) def lookup(bug): for r in cursor.execute('SELECT * FROM bugs WHERE name = ?', |