Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/config_keeps_non_ascii_characters.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed `podman-compose config` escaping non-ASCII characters, so values such as accented bind mount paths print literally instead of as `\xE9` escapes.
2 changes: 1 addition & 1 deletion podman_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -2892,7 +2892,7 @@ def _parse_compose_file(self) -> None:
if not getattr(args, "no_normalize", None):
compose = normalize_final(compose, self.dirname)
compose.pop("version", None)
self.merged_yaml = yaml.safe_dump(compose)
self.merged_yaml = yaml.safe_dump(compose, allow_unicode=True)
merged_json_b = json.dumps(
self.original_configuration(compose), separators=(",", ":")
).encode("utf-8")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
services:
sample:
image: nopush/podman-compose-test
volumes:
- /home/développement:/home/dev
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,26 @@ def test_config_short_syntax_env(self) -> None:
""")
self.assertEqual(out.decode("utf-8"), expected)

def test_config_keeps_non_ascii_characters(self) -> None:
out, _ = self.run_subprocess_assert_returncode(
[
podman_compose_path(),
"-f",
compose_yaml_path("_non_ascii"),
"config",
],
0,
)
expected = textwrap.dedent("""\
services:
sample:
image: nopush/podman-compose-test
volumes:
- /home/développement:/home/dev

""")
self.assertEqual(out.decode("utf-8"), expected)

def test_config_omits_version_and_warns(self) -> None:
config_cmd = [
"coverage",
Expand Down
35 changes: 35 additions & 0 deletions tests/unit/test_merged_yaml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SPDX-License-Identifier: GPL-2.0
# pylint: disable=protected-access
from __future__ import annotations

import os
import tempfile
import unittest

from podman_compose import PodmanCompose


class TestMergedYaml(unittest.TestCase):
def test_merged_yaml_keeps_non_ascii_characters(self) -> None:
content = """\
services:
sample:
image: nopush/podman-compose-test
volumes:
- /home/développement:/home/dev
"""

with tempfile.TemporaryDirectory() as tmp_dir:
compose_file = os.path.join(tmp_dir, "docker-compose.yaml")
with open(compose_file, "w", encoding="utf-8") as f:
f.write(content)

podman_compose = PodmanCompose()
podman_compose.global_args.file = [compose_file]
podman_compose.global_args.project_name = "test_project"
podman_compose.global_args.env_file = None
podman_compose.global_args.profile = []
podman_compose.global_args.in_pod = "false"
podman_compose._parse_compose_file()

self.assertIn("/home/développement", podman_compose.merged_yaml)