From af6a7a48533b44f1631abe7ae0b25fe598497674 Mon Sep 17 00:00:00 2001 From: Guilherme Trein Date: Tue, 29 Aug 2017 06:33:30 -0400 Subject: [PATCH] Prevent KeyError when accessing unavailable attributes --- pynder/models/user.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pynder/models/user.py b/pynder/models/user.py index 05c8407..9d7b476 100644 --- a/pynder/models/user.py +++ b/pynder/models/user.py @@ -33,12 +33,12 @@ def __init__(self, data, session): @property def instagram_username(self): if "instagram" in self._data: - return self._data['instagram']['username'] + return self._data['instagram'].get('username') @property def instagram_photos(self): if "instagram" in self._data: - return [p for p in self._data['instagram']['photos']] + return [p for p in self._data['instagram'].get('photos', [])] @property def gender(self):