From 8f4a0379eacb19320fe1c276c6e32f3313f1a988 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 18 Dec 2020 11:26:10 -0500 Subject: [PATCH 1/4] Correct examples. --- src/allmydata/test/common_util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/allmydata/test/common_util.py b/src/allmydata/test/common_util.py index 1ad0f8242..63c39d39a 100644 --- a/src/allmydata/test/common_util.py +++ b/src/allmydata/test/common_util.py @@ -59,10 +59,10 @@ def run_cli_native(verb, *args, **kwargs): Most code should prefer ``run_cli_unicode`` which deals with all the necessary encoding considerations. - :param native_str verb: The command to run. For example, ``b"create-node"``. + :param native_str verb: The command to run. For example, ``"create-node"``. :param [native_str] args: The arguments to pass to the command. For example, - ``(b"--hostname=localhost",)``. + ``("--hostname=localhost",)``. :param [native_str] nodeargs: Extra arguments to pass to the Tahoe executable before ``verb``. From 721b02b262a538de05bd757c655dc87f274e1950 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 18 Dec 2020 11:29:51 -0500 Subject: [PATCH 2/4] Use the function I specifically wrote for this! --- src/allmydata/util/base32.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/allmydata/util/base32.py b/src/allmydata/util/base32.py index 75625c817..efad58841 100644 --- a/src/allmydata/util/base32.py +++ b/src/allmydata/util/base32.py @@ -134,8 +134,7 @@ def a2b(cs): @param cs the base-32 encoded data (as bytes) """ # Workaround Future newbytes issues by converting to real bytes on Python 2: - if hasattr(cs, "__native__"): - cs = cs.__native__() + cs = backwardscompat_bytes(cs) precondition(could_be_base32_encoded(cs), "cs is required to be possibly base32 encoded data.", cs=cs) precondition(isinstance(cs, bytes), cs) From 865f3fd7d0d0fa82dcb9ed4a75f7f12ee02004fa Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 18 Dec 2020 11:33:24 -0500 Subject: [PATCH 3/4] Improve the docstring. --- src/allmydata/test/test_system.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 192b82e78..0a5996cdc 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -70,7 +70,13 @@ from ..scripts.common import ( def run_cli(*args, **kwargs): """ - Backwards compatible version so we don't have to change all the tests. + Run a Tahoe-LAFS CLI utility, but inline. + + Version of run_cli_unicode() that takes any kind of string, and the + command-line args inline instead of as verb + list. + + Backwards compatible version so we don't have to change all the tests that + expected this API. """ nodeargs = [ensure_text(a) for a in kwargs.pop("nodeargs", [])] kwargs["nodeargs"] = nodeargs From 50a794a91154259d7d948e5fb110e520f7d40588 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 18 Dec 2020 11:34:08 -0500 Subject: [PATCH 4/4] More accurate docstring. --- src/allmydata/test/test_system.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 0a5996cdc..e8b27fa69 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -664,7 +664,7 @@ def flush_but_dont_ignore(res): def _render_config(config): """ - Convert a ``dict`` of ``dict`` of ``bytes`` to an ini-format string. + Convert a ``dict`` of ``dict`` of ``unicode`` to an ini-format string. """ return u"\n\n".join(list( _render_config_section(k, v) @@ -674,8 +674,8 @@ def _render_config(config): def _render_config_section(heading, values): """ - Convert a ``bytes`` heading and a ``dict`` of ``bytes`` to an ini-format - section as ``bytes``. + Convert a ``unicode`` heading and a ``dict`` of ``unicode`` to an ini-format + section as ``unicode``. """ return u"[{}]\n{}\n".format( heading, _render_section_values(values) @@ -683,8 +683,8 @@ def _render_config_section(heading, values): def _render_section_values(values): """ - Convert a ``dict`` of ``bytes`` to the body of an ini-format section as - ``bytes``. + Convert a ``dict`` of ``unicode`` to the body of an ini-format section as + ``unicode``. """ return u"\n".join(list( u"{} = {}".format(k, v)