cgrok / clashroyale

Async + Sync wrapper for royaleapi.com and the CR official API
MIT License
47 stars 19 forks source link

TypeError: join() argument must be str or bytes, not 'WindowsPath' #25

Closed gogaz closed 6 years ago

gogaz commented 6 years ago

I am running Python3.5.4 on Windows 10 and am getting an error when trying to use OfficialAPI, stack-trace below :

File "C:\Users\...\pull.py", line 14, in <module>
    APIClient = clashroyale.OfficialAPI(settings.API_KEY, timeout=30)
  File "C:\Users\...\venv\lib\site-packages\clashroyale\official_api\client.py", line 104, in __init__
    with open(os.path.join(Path(__file__).parent.parent, 'constants.json'), encoding='utf8') as f:
  File "C:\Users\Username\AppData\Local\Programs\Python\Python35\lib\ntpath.py", line 113, in join
    genericpath._check_arg_types('join', path, *paths)
  File "C:\Users\Username\AppData\Local\Programs\Python\Python35\lib\genericpath.py", line 143, in _check_arg_types
    (funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'WindowsPath'
gogaz commented 6 years ago

After applying this commit I have the following stack-trace:

File "C:\Users\...\pull.py", line 14, in <module>
    APIClient = clashroyale.OfficialAPI(settings.ROYALE_API_KEY, timeout=30)
  File "C:\Users\...\venv\lib\site-packages\clashroyale\official_api\client.py", line 104, in __init__
    with open(Path(__file__).parent.parent.joinpath('constants.json'), encoding='utf8') as f:
TypeError: invalid file: WindowsPath('C:/Users/.../venv/lib/site-packages/clashroyale/constants.json')
gogaz commented 6 years ago

I was finally able to use OfficialAPI with this line:

with Path(__file__).parent.parent.joinpath('constants.json').open(encoding='utf8') as f: