clashroyale icon indicating copy to clipboard operation
clashroyale copied to clipboard

AttributeError: __enter__ when trying sync example from stable

Open Amleto opened this issue 5 years ago • 2 comments

I used python 3.6, clashroyale 4.0.1, in win 10 console and pasted the sync example lines, except adding my api token. I ran into the following error,

>>> profile = client.get_player('#8l9l9gl')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python\Python36-32\lib\site-packages\clashroyale\official_api\utils.py", line 35, in wrapper
    return func(*new_args, **new_kwargs)
  File "C:\Python\Python36-32\lib\site-packages\clashroyale\official_api\client.py", line 248, in get_player
    return self._get_model(url, FullPlayer, timeout=timeout)
  File "C:\Python\Python36-32\lib\site-packages\clashroyale\official_api\client.py", line 231, in _get_model
    raise e
  File "C:\Python\Python36-32\lib\site-packages\clashroyale\official_api\client.py", line 224, in _get_model
    data, cached, ts, resp = self._request(url, **params)
  File "C:\Python\Python36-32\lib\site-packages\clashroyale\official_api\client.py", line 178, in _request
    method, url, timeout=timeout, headers=self.headers, params=params, json=json_data
AttributeError: __enter__

Amleto avatar Dec 20 '19 00:12 Amleto

believe this is due to requests lib version... I had 2.17, upgraded to 2.20 and this went away, hence you need to put a minimum version in the requirements.

Amleto avatar Dec 20 '19 00:12 Amleto

Feel free to open a new PR, also make sure to read CONTRIBUTING.md before submitting it 😉

gogaz avatar Dec 22 '19 12:12 gogaz