[py3] Decode subprocess stdout in toolsutils.show_diffs() 3.26
authorDenis Laxalde <denis.laxalde@logilab.fr>
Wed, 06 Jun 2018 11:56:15 +0200
branch3.26
changeset 12321 e116275bf1ac
parent 12320 d46753a9a2a5
child 12322 cd211bb9aa8e
[py3] Decode subprocess stdout in toolsutils.show_diffs() On Python 3, subprocess' pipes are bytes stream so we must decode them before printing. Without this change, diff of configuration files (e.g. all-in-one.conf as displayed upon instance upgrade) will rendered as a single line on Python 3.
cubicweb/toolsutils.py
--- a/cubicweb/toolsutils.py	Thu May 03 16:47:51 2018 +0200
+++ b/cubicweb/toolsutils.py	Wed Jun 06 11:56:15 2018 +0200
@@ -96,7 +96,7 @@
     """
     import shutil
     pipe = subprocess.Popen(['diff', '-u', appl_file, ref_file], stdout=subprocess.PIPE)
-    diffs = pipe.stdout.read()
+    diffs = pipe.stdout.read().decode('utf-8')
     if diffs:
         if askconfirm:
             print()