diff --git a/pubs/configs.py b/pubs/configs.py index 50e13de..7e09b88 100644 --- a/pubs/configs.py +++ b/pubs/configs.py @@ -66,12 +66,12 @@ class Config(object): if not check_file(path, fail=False): raise IOError(("The configuration file {} does not exist." " Did you run 'pubs init' ?").format(path)) - with _open(path, 'r') as f: + with _open(path, 'rb+') as f: _read_config(self._cfg, f) return self def save(self, path=DFT_CONFIG_PATH): - with _open(path, 'w') as f: + with _open(path, 'wb+') as f: self._cfg.write(f) def __setattr__(self, name, value): diff --git a/pubs/content.py b/pubs/content.py index b646b7c..d442ea2 100644 --- a/pubs/content.py +++ b/pubs/content.py @@ -15,7 +15,7 @@ from .p3 import urlparse, HTTPConnection, urlopen """ -ENCODING = 'utf8' +ENCODING = 'UTF-8' # files i/o @@ -45,7 +45,10 @@ def system_path(path): def _open(path, mode): - return io.open(system_path(path), mode, encoding=ENCODING) + if mode.find('b') == -1: + return io.open(system_path(path), mode, encoding=ENCODING) + else: + return io.open(system_path(path), mode)#, encoding=ENCODING) def check_file(path, fail=True):