[meld/Python3: 17/54] misc: Fix fallbackdecode for py3k, and rename keyword
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/Python3: 17/54] misc: Fix fallbackdecode for py3k, and rename keyword
- Date: Sun, 1 May 2016 22:23:26 +0000 (UTC)
commit 06683cb5fee04a31e7e622101d9c122625ad2cc3
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Nov 14 06:55:16 2015 +1000
misc: Fix fallbackdecode for py3k, and rename keyword
meld/misc.py | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/meld/misc.py b/meld/misc.py
index 8c14042..96c8637 100644
--- a/meld/misc.py
+++ b/meld/misc.py
@@ -206,7 +206,7 @@ def gdk_to_cairo_color(color):
return (color.red / 65535., color.green / 65535., color.blue / 65535.)
-def fallback_decode(bytes, encodings, lossy=False):
+def fallback_decode(bytestring, encodings, lossy=False):
"""Try and decode bytes according to multiple encodings
Generally, this should be used for best-effort decoding, when the
@@ -215,20 +215,20 @@ def fallback_decode(bytes, encodings, lossy=False):
If lossy is True, then decode errors will be replaced. This may be
reasonable when the string is for display only.
"""
- if isinstance(bytes, unicode):
- return bytes
+ if isinstance(bytestring, str):
+ return bytestring
for encoding in encodings:
try:
- return bytes.decode(encoding)
+ return bytestring.decode(encoding)
except UnicodeDecodeError:
pass
if lossy:
- return bytes.decode(encoding, errors='replace')
+ return bytestring.decode(encoding, errors='replace')
raise ValueError(
- "Couldn't decode %r as one of %r" % (bytes, encodings))
+ "Couldn't decode %r as one of %r" % (bytestring, encodings))
def all_same(lst):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]