From 7cb1626bdc5a57d8fd193ed9bcc4191d27525f12 Mon Sep 17 00:00:00 2001 From: Curious Crook <70259149+CuriousCrook@users.noreply.github.com> Date: Mon, 27 Sep 2021 10:21:14 +0200 Subject: [PATCH] Fix crash if server does not provide DiscoveryUrls The OPC UA specification does not forbid that a server does not offer DiscoveryUrls. This can lead to a crash when calling the function application_to_strings(). Check DiscoveryUrls for None or empty before iterating to avoid the crash described in #1127. --- opcua/tools.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/opcua/tools.py b/opcua/tools.py index 889cd5fe6..cc93269eb 100644 --- a/opcua/tools.py +++ b/opcua/tools.py @@ -418,8 +418,9 @@ def application_to_strings(app): for (n, v) in optionals: if v: result.append((n, v)) - for url in app.DiscoveryUrls: - result.append(('Discovery URL', url)) + if app.DiscoveryUrls: + for url in app.DiscoveryUrls: + result.append(('Discovery URL', url)) return result # ['{}: {}'.format(n, v) for (n, v) in result]