Patchwork tests: avoid implicit bytes -> unicode -> bytes roundtrip on Python 2

login
register
mail settings
Submitter Manuel Jacob
Date March 9, 2020, 12:17 a.m.
Message ID <ae4272a4f77c327ff08d.1583713042@tmp>
Download mbox | patch
Permalink /patch/45624/
State Accepted
Headers show

Comments

Manuel Jacob - March 9, 2020, 12:17 a.m.
# HG changeset patch
# User Manuel Jacob <me@manueljacob.de>
# Date 1583486858 -3600
#      Fri Mar 06 10:27:38 2020 +0100
# Node ID ae4272a4f77c327ff08d48d50460d573fe003757
# Parent  2b5c4788d7f0aaf56775c0a2a032727255367c6c
# EXP-Topic remove-implicit-str-conversions
tests: avoid implicit bytes -> unicode -> bytes roundtrip on Python 2

Before the change, there were two implicit conversions:

* The format string was converted to unicode because the substituted values were
  unicode.
* When printing the message in log(), the string was converted from unicode to
  str.
Yuya Nishihara - March 9, 2020, 1:45 p.m.
On Mon, 09 Mar 2020 01:17:22 +0100, Manuel Jacob wrote:
> # HG changeset patch
> # User Manuel Jacob <me@manueljacob.de>
> # Date 1583486858 -3600
> #      Fri Mar 06 10:27:38 2020 +0100
> # Node ID ae4272a4f77c327ff08d48d50460d573fe003757
> # Parent  2b5c4788d7f0aaf56775c0a2a032727255367c6c
> # EXP-Topic remove-implicit-str-conversions
> tests: avoid implicit bytes -> unicode -> bytes roundtrip on Python 2

Queued, thanks.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1166,8 +1166,8 @@ 
             log(
                 '\nKeeping testtmp dir: %s\nKeeping threadtmp dir: %s'
                 % (
-                    self._testtmp.decode('utf-8'),
-                    self._threadtmp.decode('utf-8'),
+                    _bytes2sys(self._testtmp),
+                    _bytes2sys(self._threadtmp),
                 )
             )
         else: