The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.
Fix PreviewAny escaping non-ASCII text in dict and list previews (#15513)
Christian Byrne26d7f8556822
diff --git a/comfy_extras/nodes_preview_any.py b/comfy_extras/nodes_preview_any.pyindex d985f3287..18bf7c1cd 100644--- a/comfy_extras/nodes_preview_any.py+++ b/comfy_extras/nodes_preview_any.py@@ -29,7 +29,7 @@ class PreviewAny():value = str(source)elif source is not None:try:- value = json.dumps(source, indent=4)+ value = json.dumps(source, indent=4, ensure_ascii=False)except Exception:try:value = str(source)diff --git a/tests-unit/comfy_extras_test/nodes_preview_any_test.py b/tests-unit/comfy_extras_test/nodes_preview_any_test.pynew file mode 100644index 000000000..563c1f1b0--- /dev/null+++ b/tests-unit/comfy_extras_test/nodes_preview_any_test.py@@ -0,0 +1,30 @@+from unittest.mock import patch, MagicMock++mock_nodes = MagicMock()+mock_nodes.MAX_RESOLUTION = 16384+mock_server = MagicMock()++with patch.dict("sys.modules", {"nodes": mock_nodes, "server": mock_server}):+ from comfy_extras.nodes_preview_any import PreviewAny+++class TestPreviewAnyMain:+ @staticmethod+ def _exec(source) -> dict:+ return PreviewAny().main(source)++ def test_dict_keeps_non_ascii(self):+ result = self._exec({"greeting": "你好"})+ assert "你好" in result["ui"]["text"][0]+ assert "\\u" not in result["ui"]["text"][0]+ assert result["result"][0] == result["ui"]["text"][0]++ def test_list_keeps_non_ascii(self):+ result = self._exec(["你好", "こんにちは"])+ assert "こんにちは" in result["result"][0]+ assert "\\u" not in result["result"][0]++ def test_string_passthrough(self):+ result = self._exec("你好")+ assert result["ui"]["text"][0] == "你好"+ assert result["result"][0] == "你好"