Fix py2 compatibility

master
J. Fernando Sánchez 6 years ago
parent 27bc3557b2
commit 7c829ee102

@ -1 +1 @@
0.7.6
0.7.7

@ -30,6 +30,12 @@ from bitter.models import Following, User, ExtractorEntry, make_session
from bitter import config
# Fix Python 2.x.
try:
UNICODE_EXISTS = bool(type(unicode))
except NameError:
unicode = lambda s: str(s)
logger = logging.getLogger(__name__)
@ -90,7 +96,7 @@ def read_config(conffile):
elif 'BITTER_CONFIG' not in os.environ:
raise Exception('No config file or BITTER_CONFIG env variable.')
else:
f = io.StringIO(os.environ.get('BITTER_CONFIG', "").strip().replace('\\n', '\n'))
f = io.StringIO(unicode(os.environ.get('BITTER_CONFIG', "")).strip().replace('\\n', '\n'))
return yaml.load(f) or {'credentials': []}

Loading…
Cancel
Save