diff options
author | Emilio Pozuelo Monfort <pochu@debian.org> | 2020-07-16 17:47:49 +0200 |
---|---|---|
committer | Emilio Pozuelo Monfort <pochu@debian.org> | 2020-07-29 10:20:41 +0200 |
commit | 8f9080919992cf9761ecada4a38eaa56f1791d54 (patch) | |
tree | 08cd4474c85c7ecc265529e17cbdd65f346e178a /lib | |
parent | 089e4e7f44a3d7a55945ff52274920a8c6bdfc90 (diff) |
debian_support.py: add py3 compatibility for apt-update-file
Diffstat (limited to 'lib')
-rw-r--r-- | lib/python/debian_support.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/python/debian_support.py b/lib/python/debian_support.py index a51435caf3..ba824775ab 100644 --- a/lib/python/debian_support.py +++ b/lib/python/debian_support.py @@ -19,6 +19,7 @@ from __future__ import print_function """This module implements facilities to deal with Debian-specific metadata.""" import gzip +import io import json import os.path import re @@ -150,7 +151,7 @@ class PackageFile: self.lineno = 0 def __iter__(self): - line = self.file.readline() + line = self.file.readline().decode('utf-8') self.lineno += 1 pkg = [] while line: @@ -159,7 +160,7 @@ class PackageFile: self.raiseSyntaxError('expected package record') yield pkg pkg = [] - line = self.file.readline() + line = self.file.readline().decode('utf-8') self.lineno += 1 continue @@ -170,7 +171,7 @@ class PackageFile: contents = contents or '' while True: - line = self.file.readline() + line = self.file.readline().decode('utf-8') self.lineno += 1 match = self.re_continuation.match(line) if match: @@ -222,6 +223,8 @@ 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) return m.hexdigest() @@ -306,7 +309,10 @@ def downloadGunzipLines(remote): try: gfile = gzip.GzipFile(fileobj=streamIO(data.read())) try: - return gfile.readlines() + if sys.version_info.major == 3: + return io.TextIOWrapper(gfile).readlines() + else: + return gfile.readlines() finally: gfile.close() finally: |