Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error on fresh install with simplejson #16

Open
vshesh opened this issue Oct 27, 2020 · 6 comments
Open

error on fresh install with simplejson #16

vshesh opened this issue Oct 27, 2020 · 6 comments
Labels
dependencies Pull requests that update a dependency file

Comments

@vshesh
Copy link

vshesh commented Oct 27, 2020

  • berserk version: 0.10.0
  • Python version: 3.8.5
  • Operating System: Mac OS 10.13

Description

installed berserk a few minutes ago

Describe what you were trying to get done.

import berserk
client = berserk.Client(berserk.SessionToken('...'))
client.account.get()

Tell us what happened, what went wrong, and what you expected to happen.

Traceback (most recent call last):
  File "<input>", line 1, in <module>
    client.account.get()
  File "/usr/local/lib/python3.8/site-packages/berserk/clients.py", line 115, in get
    return self._r.get(path, converter=models.Account.convert)
  File "/usr/local/lib/python3.8/site-packages/berserk/session.py", line 60, in get
    return self.request('GET', *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/berserk/session.py", line 56, in request
    return fmt.handle(response, is_stream=is_stream, converter=converter)
  File "/usr/local/lib/python3.8/site-packages/berserk/formats.py", line 35, in handle
    return converter(self.parse(response))
  File "/usr/local/lib/python3.8/site-packages/berserk/formats.py", line 76, in parse
    return response.json(cls=self.decoder)
  File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 889, in json
    return complexjson.loads(
  File "/usr/local/lib/python3.8/site-packages/simplejson/__init__.py", line 542, in loads
TypeError: __init__() got an unexpected keyword argument 'encoding'

error is happening somewhere deep in the simplejson code. uninstalling simplejson makes the function work, but I shouldn't need to do this - I use simplejson in many other places (and other libraries depend on it) and so this is a bug for me. I tried to debug it myself for a but but could not understand why this error was appearing - the parameters look fine.

@vshesh
Copy link
Author

vshesh commented Oct 27, 2020

Ok, looks like this is some kind of known issue that requires a monkeypatch in the user libraries, since requests library is not solving the problem... psf/requests#4842

@9acca9
Copy link

9acca9 commented Oct 29, 2020

Oh, i think that my problem is the same:
#17

"this is some kind of known issue that requires a monkeypatch in the user libraries". What is the meaning of this? (i dont speak english)

Thanks.

@vshesh so, you could fix this?

@vshesh
Copy link
Author

vshesh commented Oct 29, 2020

The real issue is with the requests library, so the way I fixed it is I got rid of the simplejson import within that library.
I'm not sure how familiar with python you are.... the way to do this is to go to the requests library package folder and change the code there. There's a compat file that exports a variable json - i replaced that code with import json instead.

this is not a good solution, actually, it's a terrible one. But it works and it solves the problem at the source rather than requiring a lot of upstream changes.

@9acca9
Copy link

9acca9 commented Oct 29, 2020

@vshesh Oh... i uninstall SimpleJson.... im gonna look for what you say.
about "how familiar with python"... prebeginner.

Thanks for your work.

@PinyaColada
Copy link

I have the same problem, it will be fixed soon? changing the code of your copy of the library is terrible and not a practical solution

@mattrussell2
Copy link

My solution was to remove encoding=encoding from line 535 in __init__.py of the simplejson package...yuck

@rhgrant10 rhgrant10 added the dependencies Pull requests that update a dependency file label Apr 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

5 participants