From fb595849bc7149619b3e47b65f145a1f66fc7dbe Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 1 Dec 2011 13:45:58 +0100 Subject: fix debfile binary test for py3 --- apt/debfile.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'apt') diff --git a/apt/debfile.py b/apt/debfile.py index 104b0814..4a82842a 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -525,12 +525,19 @@ class DebPackage(object): @staticmethod def to_strish(in_data): + # helper for py3 compat, in_data is str in py2 and bytes in py3 + def my_ord(c): + if type(c) == int: + return c + else: + return ord(c) + # convert s = "" for c in in_data: - if ord(c) < 10 or ord(c) > 127: + if my_ord(c) < 10 or my_ord(c) > 127: s += " " else: - s += c + s += chr(c) return s def _get_content(self, part, name, auto_decompress=True, auto_hex=True): -- cgit v1.2.3