From 9923742e74f86d495a412a6208fd57e7563b0597 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 14 May 2018 19:06:11 +0200 Subject: [PATCH] Prevent plugins from breaking in case of concatenations with None elements --- platypush/message/request/__init__.py | 5 ++++- platypush/plugins/google/maps.py | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/platypush/message/request/__init__.py b/platypush/message/request/__init__.py index e8863263..127fd9f7 100644 --- a/platypush/message/request/__init__.py +++ b/platypush/message/request/__init__.py @@ -135,7 +135,10 @@ class Request(Message): else: try: - parsed_value += prefix + eval(inner_expr) + expanded_expr = eval(inner_expr) + parsed_value += prefix + if expanded_expr is not None: + parsed_value += expanded_expr except Exception as e: logging.exception(e) parsed_value += prefix + expr diff --git a/platypush/plugins/google/maps.py b/platypush/plugins/google/maps.py index 55eb7f5f..a5ca675e 100644 --- a/platypush/plugins/google/maps.py +++ b/platypush/plugins/google/maps.py @@ -44,7 +44,11 @@ class GoogleMapsPlugin(GooglePlugin): address['postal_code'] = addr_component['long_name'] if 'address' in address and 'street_number' in address: - address['address'] += ' ' + address['street_number'] + address['address'] = '{}{}{}'.format( + (address['address'] or ''), + (' ' if address['street_number'] else ''), + (address['street_number'] or '')) + del(address['street_number']) return Response(output=address)