summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <pochu@debian.org>2020-07-16 17:47:49 +0200
committerEmilio Pozuelo Monfort <pochu@debian.org>2020-07-29 10:20:41 +0200
commit40bea495dab92cde18bf41acea83b8e76f55bcf9 (patch)
tree5b3d2e8ec42d08c7269e98403311dfbe9780ae26 /lib
parent6a8f2e849415f111279f28bd91533fb302151125 (diff)
debian_support.py: add py3 compatibility for apt-update-file
Diffstat (limited to 'lib')
-rw-r--r--lib/python/debian_support.py14
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:

© 2014-2024 Faster IT GmbH | imprint | privacy policy