From 8c30ea0be6c532c81823ba2da9a13ef3bd21b2b2 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 3 Apr 2019 16:43:37 -0400 Subject: [PATCH] [core] Fix logging with unset DATADOG_PATCH_MODULES If DATADOG_PATCH_MODULES is unset, the default value was '' which when used with .split(',') does not return 2 items, logging that the patch instruction is malformed. This patch fixes that by checking that the value is set and non empty before trying to patch anything. --- ddtrace/bootstrap/sitecustomize.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ddtrace/bootstrap/sitecustomize.py b/ddtrace/bootstrap/sitecustomize.py index 59bf0281dec..b4f0b6f4a05 100644 --- a/ddtrace/bootstrap/sitecustomize.py +++ b/ddtrace/bootstrap/sitecustomize.py @@ -46,7 +46,10 @@ def update_patched_modules(): - for patch in os.environ.get("DATADOG_PATCH_MODULES", '').split(','): + modules_to_patch = os.environ.get("DATADOG_PATCH_MODULES") + if not modules_to_patch: + return + for patch in modules_to_patch.split(','): if len(patch.split(':')) != 2: log.debug("skipping malformed patch instruction") continue