!10 Fix encode during show(stdout=True)

From: @zhang-liang-pengkun 
Reviewed-by: @chenwei_kernel 
Signed-off-by: @chenwei_kernel
This commit is contained in:
openeuler-ci-bot 2025-04-22 10:19:38 +00:00 committed by Gitee
commit 4864707660
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,30 @@
From 7f124327e8954bbcda68c2832f20b1d0d7a4808b Mon Sep 17 00:00:00 2001
From: kiraskyler <80014218+kiraskyler@users.noreply.github.com>
Date: Sat, 1 Mar 2025 23:35:22 +0800
Subject: [PATCH] Fix encode during show(stdout=True) (#230)
Co-authored-by: niuwanli <niuwanli@cqsoftware.com.cn>
---
treelib/tree.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/treelib/tree.py b/treelib/tree.py
index e27200f..b16baa4 100644
--- a/treelib/tree.py
+++ b/treelib/tree.py
@@ -948,6 +948,7 @@ def show(
:param reverse: the ``reverse`` param for sorting :class:`Node` objects in the same level.
:param line_type:
:param data_property: the property on the node data object to be printed.
+ :param stdout: if True print it, if False return printing.
:param sorting: if True perform node sorting, if False return
nodes in original insertion order. In latter case @key and
@reverse parameters are ignored.
@@ -975,7 +976,7 @@ def write(line):
print("Tree is empty")
if stdout:
- print(self._reader.encode("utf-8"))
+ print(self._reader)
else:
return self._reader

View File

@ -1,12 +1,13 @@
%global _empty_manifest_terminate_build 0
Name: python-treelib
Version: 1.7.0
Release: 2
Release: 3
Summary: A Python 2/3 implementation of tree structure.
License: Apache-2.0
URL: https://github.com/caesar0301/treelib
Source0: https://files.pythonhosted.org/packages/d8/ec/962387a2bd7ece011f47cfa08f06f832fc9fd41b31f4f0007b8b7948eb93/treelib-1.7.0.tar.gz
Patch6000: Escape-double-quotes-in-graphviz-labels.patch
Patch6001: Fix-encode-during-show-stdout-True.patch
BuildArch: noarch
@ -70,6 +71,9 @@ mv %{buildroot}/doclist.lst .
%{_docdir}/*
%changelog
* Mon Apr 21 2025 zhangliangpengkun <zhangliangpengkun@xfusion.com> - 1.7.0-3
- DESC:Fix encode during show(stdout=True)
* Fri Apr 18 2025 zhangliangpengkun <zhangliangpengkun@xfusion.com> - 1.7.0-2
- DESC:Escape double quotes in graphviz labels