Skip to content

Commit caf0809

Browse files
authored
Merge pull request conda#7873 from geremih/fix/write-repodata-as-unicode
Encode repodata to utf-8 while caching
2 parents 7495d9b + b718352 commit caf0809

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

conda/core/subdir_data.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import re
1717
from time import time
1818
import warnings
19+
from io import open as io_open
1920

2021
from .. import CondaError
2122
from .._vendor.auxlib.ish import dals
@@ -226,7 +227,7 @@ def _load(self):
226227
if not isdir(dirname(self.cache_path_json)):
227228
mkdir_p(dirname(self.cache_path_json))
228229
try:
229-
with open(self.cache_path_json, 'w') as fh:
230+
with io_open(self.cache_path_json, 'w') as fh:
230231
fh.write(raw_repodata_str or '{}')
231232
except (IOError, OSError) as e:
232233
if e.errno in (EACCES, EPERM):
@@ -550,12 +551,12 @@ def maybe_decompress(filename, resp_content):
550551

551552
# add extra values to the raw repodata json
552553
if json_str and json_str != "{}":
553-
raw_repodata_str = "%s, %s" % (
554+
raw_repodata_str = u"%s, %s" % (
554555
json.dumps(saved_fields)[:-1], # remove trailing '}'
555556
json_str[1:] # remove first '{'
556557
)
557558
else:
558-
raw_repodata_str = json.dumps(saved_fields)
559+
raw_repodata_str = ensure_text_type(json.dumps(saved_fields))
559560
return raw_repodata_str
560561

561562

0 commit comments

Comments
 (0)