From 8d3d964dafe86837e3e1e29fc23232cd1890ad34 Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Sat, 25 Apr 2015 16:50:00 +0200 Subject: [PATCH] Disable a code path for encoded yaml in python3 The comment says we should no longer need that. Signed-off-by: Julien Cristau --- excuse.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/excuse.py b/excuse.py index 7f87ae8..e0e1a3f 100644 --- a/excuse.py +++ b/excuse.py @@ -15,7 +15,7 @@ # GNU General Public License for more details. import re - +import six class Excuse(object): """Excuse class @@ -183,10 +183,11 @@ class Excuse(object): maint = self.maint # ugly hack to work around strange encoding in pyyaml # should go away with pyyaml in python 3 - try: - maint.decode('ascii') - except UnicodeDecodeError: - maint = unicode(self.maint,'utf-8') + if isinstance(maint, six.binary_type): + try: + maint.decode('ascii') + except UnicodeDecodeError: + maint = six.string_type(self.maint,'utf-8') res.append("Maintainer: %s" % maint) if self.section and self.section.find("/") > -1: res.append("Section: %s" % (self.section))