Commit c75baaa1 by Toshio Kuratomi

Merge pull request #10630 from viesti/viesti-master

Use codecs module while reading & writing json cache file
parents fe2cc6dd 9409cc74
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
import os import os
import time import time
import errno import errno
import codecs
try: try:
import simplejson as json import simplejson as json
...@@ -57,7 +58,7 @@ class CacheModule(BaseCacheModule): ...@@ -57,7 +58,7 @@ class CacheModule(BaseCacheModule):
cachefile = "%s/%s" % (self._cache_dir, key) cachefile = "%s/%s" % (self._cache_dir, key)
try: try:
f = open( cachefile, 'r') f = codecs.open(cachefile, 'r', encoding='utf-8')
except (OSError,IOError), e: except (OSError,IOError), e:
utils.warning("error while trying to write to %s : %s" % (cachefile, str(e))) utils.warning("error while trying to write to %s : %s" % (cachefile, str(e)))
else: else:
...@@ -73,7 +74,7 @@ class CacheModule(BaseCacheModule): ...@@ -73,7 +74,7 @@ class CacheModule(BaseCacheModule):
cachefile = "%s/%s" % (self._cache_dir, key) cachefile = "%s/%s" % (self._cache_dir, key)
try: try:
f = open(cachefile, 'w') f = codecs.open(cachefile, 'w', encoding='utf-8')
except (OSError,IOError), e: except (OSError,IOError), e:
utils.warning("error while trying to read %s : %s" % (cachefile, str(e))) utils.warning("error while trying to read %s : %s" % (cachefile, str(e)))
else: else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment