params: support unicode characters (#5363)

* params: support unicode characters

* open remove() calls with utf-8
This commit is contained in:
Batuhan Taskaya
2021-02-01 15:56:53 +02:00
committed by GitHub
parent 13db267a5d
commit c84833bab1
2 changed files with 15 additions and 3 deletions
+3 -3
View File
@@ -131,7 +131,7 @@ class FileMixin:
raise StageFileIsNotDvcFileError(self.path)
if self._is_git_ignored():
raise FileIsGitIgnored(self.path)
with self.repo.tree.open(self.path) as fd:
with self.repo.tree.open(self.path, encoding="utf-8") as fd:
stage_text = fd.read()
d = parse_yaml(stage_text, self.path)
return self.validate(d, self.relpath), stage_text
@@ -276,7 +276,7 @@ class PipelineFile(FileMixin):
if not self.exists():
return
with open(self.path, "r") as f:
with open(self.path, "r", encoding="utf-8") as f:
d = parse_yaml_for_update(f.read(), self.path)
self.validate(d, self.path)
@@ -380,7 +380,7 @@ class Lockfile(FileMixin):
if not self.exists():
return
with open(self.path) as f:
with open(self.path, encoding="utf-8") as f:
d = parse_yaml_for_update(f.read(), self.path)
self.validate(d, self.path)
+12
View File
@@ -20,3 +20,15 @@ def test_params_order(tmp_dir, dvc, dummy_stage):
# params are sorted during dumping, therefore p1 is first
assert list(dvc.params.show()[""]) == ["p1.yaml", p2_path, "params.yaml"]
def test_repro_unicode(tmp_dir, dvc, dummy_stage):
tmp_dir.gen({"settings.json": '{"Ω_value": 1}'})
dummy_stage(params=[{"settings.json": ["Ω_value"]}])
(stage,) = dvc.reproduce(dry=True)
stage.cmd = "foo"
stage.dvcfile._lockfile.dump(stage)
dvc.remove(stage.name)
assert not (tmp_dir / "dvc.yaml").exists()
assert not (tmp_dir / "dvc.lock").exists()