taizilongxu / douban.fm

:radio: douban.fm based on Python
MIT License
786 stars 190 forks source link

UnboundLocalError #82

Closed huiyiqun closed 9 years ago

huiyiqun commented 9 years ago

Here is part of the exception:

File ".../douban.fm/build/lib/douban/douban_token.py", line 149, in requests_url
      return s.text
UnboundLocalError: local variable 's' referenced before assignment

It refers following code.

        try:
            s = requests.get(url)
        except requests.exceptions.RequestException:
            logger.error("Error communicating with Douban.fm API.")
        return s.text

It looks like that if requests.get failed, then s is unbound.