oanda / oandapy

Python wrapper for the OANDA REST API
MIT License
321 stars 147 forks source link

Fix "'response' referenced before assignment" #35

Closed hamx0r closed 7 years ago

hamx0r commented 7 years ago

The try/except block in request() causes response and content to be referenced before assignment. I moved some code into the try block and added a line in except to cause meaningful information to be passed back to user in response, and prevent the use of response before assignment

Traceback (most recent call last):
 ...
  File "oandapy/oandapy.py", line 38, in get_history
    return self.request(endpoint, params=params)
  File "oandapy/oandapy.py", line 269, in request
    content = response.content.decode('utf-8')
UnboundLocalError: local variable 'response' referenced before assignment