[PATCH] tests: avoid implicit conversion of str to unicode
Manuel Jacob
me at manueljacob.de
Fri Mar 6 09:35:05 UTC 2020
# HG changeset patch
# User Manuel Jacob <me at manueljacob.de>
# Date 1583428219 -3600
# Thu Mar 05 18:10:19 2020 +0100
# Node ID 14e2295705434054ed9c697143bb7207ebd1777d
# Parent 4cabeea6d21456ae4d560ef72adffe11d77d5387
# EXP-Topic remove-implicit-str-conversions
tests: avoid implicit conversion of str to unicode
On Python 2, str.encode('ascii') implicitly converts the string to unicode and
then back to str.
Since the point of this expression is to convert a bool to a str, the '%r'
conversion specifier can be used instead in the format string.
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1428,7 +1428,7 @@
)
hgrc.write(b'[web]\n')
hgrc.write(b'address = localhost\n')
- hgrc.write(b'ipv6 = %s\n' % str(self._useipv6).encode('ascii'))
+ hgrc.write(b'ipv6 = %r\n' % self._useipv6)
hgrc.write(b'server-header = testing stub value\n')
for opt in self._extraconfigopts:
More information about the Mercurial-devel
mailing list