From 2e31f9bdc5a6aa5c70450a10d7425a36927bf9d7 Mon Sep 17 00:00:00 2001 From: Arnaud Legendre Date: Fri, 1 Aug 2014 19:16:09 -0700 Subject: [PATCH] _trunc_id to check if the session_id is not None The current code will raise a TypeError if the session_id is None: TypeError: 'NoneType' object has no attribute '__getitem__' This will happen specifically when _trunc_id is called by _is_current_session_active. This patch adds a check to make sure session_id is not None. Change-Id: Ifc3cc236f36df1a140b864e53e9eb538797e5580 --- oslo/vmware/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/oslo/vmware/api.py b/oslo/vmware/api.py index 2705c8ab..a24aea58 100644 --- a/oslo/vmware/api.py +++ b/oslo/vmware/api.py @@ -39,7 +39,8 @@ LOG = logging.getLogger(__name__) def _trunc_id(session_id): """Returns truncated session id which is suitable for logging.""" - return session_id[-5:] + if session_id is not None: + return session_id[-5:] # TODO(vbala) Move this class to excutils.py.