mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
params: support unicode characters (#5363)
* params: support unicode characters * open remove() calls with utf-8
This commit is contained in:
+3
-3
@@ -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)
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user