From a978fcf433816174c521a236361392c37b1f1f48 Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Thu, 26 Nov 2020 19:35:39 -0500 Subject: [PATCH] Replace asserts with explicit checks and TypeError --- src/allmydata/node.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/allmydata/node.py b/src/allmydata/node.py index 7eefbbce0..6253aad4b 100644 --- a/src/allmydata/node.py +++ b/src/allmydata/node.py @@ -463,11 +463,34 @@ class _Config(object): for petname, config in introducers_yaml.get("introducers", {}).items() } - assert all(isinstance(k, str) for k in introducers.keys()) - assert all(isinstance(v, str) for v in introducers.values()), introducers.values() + non_strs = list( + k + for k + in introducers.keys() + if not isinstance(k, str) + ) + if non_strs: + raise TypeError( + "Introducer petnames {!r} should have been str".format( + non_strs, + ), + ) + non_strs = list( + v + for v + in introducers.values() + if not isinstance(v, str) + ) + if non_strs: + raise TypeError( + "Introducer fURLs {!r} should have been str".format( + non_strs, + ), + ) log.msg( - "found {} introducers in private/introducers.yaml".format( + "found {} introducers in {!r}".format( len(introducers), + introducers_yaml_filename, ) ) except EnvironmentError as e: