From 38ea4b6910bba81e26cdf1f9aa5ebf0c7ddef4f9 Mon Sep 17 00:00:00 2001 From: Paul Lamere Date: Fri, 12 Feb 2016 07:24:28 -0500 Subject: [PATCH] better handling when missing json payload --- spotipy/client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spotipy/client.py b/spotipy/client.py index 06fb1c9..dbd51d2 100644 --- a/spotipy/client.py +++ b/spotipy/client.py @@ -104,7 +104,7 @@ class Spotify(object): try: r.raise_for_status() except: - if r.text: + if r.text and len(r.text) > 0 and r.text != 'null': raise SpotifyException(r.status_code, -1, '%s:\n %s' % (r.url, r.json()['error']['message'])) else: @@ -112,7 +112,7 @@ class Spotify(object): -1, '%s:\n %s' % (r.url, 'error')) finally: r.connection.close() - if len(r.text) > 0: + if r.text and len(r.text) > 0 and r.text != 'null': results = r.json() if self.trace: # pragma: no cover print('RESP', results)