diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2011-12-01 13:55:28 +0100 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2011-12-01 13:55:28 +0100 |
| commit | d236f527f85b185144875e0e7ad9102c4c2dabd0 (patch) | |
| tree | c4c7f1b1a951b44f38353e8ca4ad05d8c04deca6 | |
| parent | 1c6b01aa63e440444f00ec9e3f527e1c65a63787 (diff) | |
| download | python-apt-d236f527f85b185144875e0e7ad9102c4c2dabd0.tar.gz | |
apt/debfile.py: add py3 compat for to_strish()
| -rw-r--r-- | apt/debfile.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/apt/debfile.py b/apt/debfile.py index 4a82842a..a7202eba 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -525,19 +525,21 @@ 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 my_ord(c) < 10 or my_ord(c) > 127: - s += " " - else: - s += chr(c) + # py2 compat, in_data is type string + if type(in_data) == str: + for c in in_data: + if ord(c) < 10 or ord(c) > 127: + s += " " + else: + s += c + # py3 compat, in_data is type bytes + else: + for b in in_data: + if b < 10 or b > 127: + s += " " + else: + s += chr(b) return s def _get_content(self, part, name, auto_decompress=True, auto_hex=True): |
