From 57a0f76e1f6ed5116c1defa221ff93241f60291d Mon Sep 17 00:00:00 2001 From: fenn-cs Date: Wed, 13 Oct 2021 23:41:42 +0100 Subject: [PATCH] maintain list of positional arguments as tuple Signed-off-by: fenn-cs --- src/allmydata/test/test_eliotutil.py | 4 ++-- src/allmydata/util/eliotutil.py | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/allmydata/test/test_eliotutil.py b/src/allmydata/test/test_eliotutil.py index 3d7b2bd42..1fbb9ec8d 100644 --- a/src/allmydata/test/test_eliotutil.py +++ b/src/allmydata/test/test_eliotutil.py @@ -297,7 +297,7 @@ class LogCallDeferredTests(TestCase): self.assertThat( f(4), succeeded(Equals(16))) msg = logger.messages[0] - assertContainsFields(self, msg, {"args": {'arg_0': 4}}) + assertContainsFields(self, msg, {"args": (4,)}) @capture_logging( lambda self, logger: @@ -328,5 +328,5 @@ class LogCallDeferredTests(TestCase): return base ** exp self.assertThat(f(10, 2, message="an exponential function"), succeeded(Equals(100))) msg = logger.messages[0] - assertContainsFields(self, msg, {"args": {'arg_0': 10, 'arg_1': 2}}) + assertContainsFields(self, msg, {"args": (10, 2)}) assertContainsFields(self, msg, {"kwargs": {"message": "an exponential function"}}) diff --git a/src/allmydata/util/eliotutil.py b/src/allmydata/util/eliotutil.py index fb18ed332..997dadb8d 100644 --- a/src/allmydata/util/eliotutil.py +++ b/src/allmydata/util/eliotutil.py @@ -335,11 +335,7 @@ def log_call_deferred(action_type): kwargs = {k: bytes_to_unicode(True, kw[k]) for k in kw} # Remove complex (unserializable) objects from positional args to # prevent eliot from throwing errors when it attempts serialization - args = { - "arg_" + str(pos): bytes_to_unicode(True, a[pos]) - for pos in range(len(a)) - if is_json_serializable(a[pos]) - } + args = tuple([a[pos] for pos in range(len(a)) if is_json_serializable(a[pos])]) with start_action(action_type=action_type, args=args, kwargs=kwargs).context(): # Use addActionFinish so that the action finishes when the # Deferred fires.