From bb7ed3afc96e2bd573449d02e9e793f42f7f0718 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Tue, 17 Nov 2020 11:25:24 -0500 Subject: [PATCH] Fix the bug. --- src/allmydata/node.py | 4 ++-- src/allmydata/test/test_node.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/allmydata/node.py b/src/allmydata/node.py index 9e7143fd4..4725ff813 100644 --- a/src/allmydata/node.py +++ b/src/allmydata/node.py @@ -79,9 +79,9 @@ def _common_valid_config(): }) # Add our application versions to the data that Foolscap's LogPublisher -# reports. +# reports. Foolscap requires native strings. for thing, things_version in list(get_package_versions().items()): - app_versions.add_version(thing, things_version) + app_versions.add_version(ensure_str(thing), ensure_str(things_version)) # group 1 will be addr (dotted quad string), group 3 if any will be portnum (string) ADDR_RE = re.compile("^([1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*\.[1-9][0-9]*)(:([1-9][0-9]*))?$") diff --git a/src/allmydata/test/test_node.py b/src/allmydata/test/test_node.py index 693183ea4..010030a6f 100644 --- a/src/allmydata/test/test_node.py +++ b/src/allmydata/test/test_node.py @@ -6,7 +6,7 @@ from __future__ import division from __future__ import print_function from __future__ import unicode_literals -from future.utils import PY2 +from future.utils import PY2, native_str if PY2: from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401 @@ -46,6 +46,7 @@ from allmydata.node import ( _tub_portlocation, formatTimeTahoeStyle, UnescapedHashError, + get_app_versions, ) from allmydata.introducer.server import create_introducer from allmydata import client @@ -100,6 +101,16 @@ class TestCase(testutil.SignalMixin, unittest.TestCase): # conflict with another service to prove it. self._available_port = 22 + def test_application_versions(self): + """ + Application versions should all have the same type, the native string. + + This test is due to the Foolscap limitations, if Foolscap is fixed or + removed it can be deleted. + """ + app_types = set(type(o) for o in get_app_versions()) + self.assertEqual(app_types, {native_str}) + def _test_location( self, expected_addresses,