_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
This commit is contained in:
Arnaud Legendre 2014-08-01 19:16:09 -07:00
parent 9dafdbed9b
commit 2e31f9bdc5

View File

@ -39,6 +39,7 @@ LOG = logging.getLogger(__name__)
def _trunc_id(session_id):
"""Returns truncated session id which is suitable for logging."""
if session_id is not None:
return session_id[-5:]