summaryrefslogtreecommitdiff
path: root/reconfigure/configs/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'reconfigure/configs/base.py')
-rw-r--r--reconfigure/configs/base.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/reconfigure/configs/base.py b/reconfigure/configs/base.py
index 5d0bb61..fc2ce6f 100644
--- a/reconfigure/configs/base.py
+++ b/reconfigure/configs/base.py
@@ -1,4 +1,6 @@
import chardet
+import six
+import sys
class Reconfig (object):
@@ -36,7 +38,8 @@ class Reconfig (object):
self.content = open(self.origin, 'r').read()
self.encoding = 'utf8'
- if hasattr(self.content, 'decode'): # str (2) or bytes (3)
+ if (six.PY3 and isinstance(self.content, bytes)) or \
+ (six.PY2 and isinstance(self.content, str)):
try:
self.content = self.content.decode('utf8')
except (UnicodeDecodeError, AttributeError):