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

ImportError: cannot import name 'JSONDecodeError' #72

Closed
jeroenmeulenaar opened this issue Feb 8, 2018 · 5 comments
Closed

ImportError: cannot import name 'JSONDecodeError' #72

jeroenmeulenaar opened this issue Feb 8, 2018 · 5 comments
Assignees
Labels
Projects

Comments

@jeroenmeulenaar
Copy link

jeroenmeulenaar commented Feb 8, 2018

Steps to reproduce:

  • Running python 3.4.2 on Debian GNU/Linux 8 (jessie).
  • Installed with pip3 install bunq_sdk --upgrade
  • Run test.py which contains from bunq.sdk import context

What happens:

~ $ python3 test.py
Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from bunq.sdk import context
  File "/usr/local/lib/python3.4/dist-packages/bunq/sdk/context.py", line 6, in <module>
    from bunq.sdk.model import core
  File "/usr/local/lib/python3.4/dist-packages/bunq/sdk/model/core.py", line 1, in <module>
    from bunq.sdk import client
  File "/usr/local/lib/python3.4/dist-packages/bunq/sdk/client.py", line 2, in <module>
    from json import JSONDecodeError
ImportError: cannot import name 'JSONDecodeError'

SDK version and environment

needs #78

@OGKevin
Copy link
Contributor

OGKevin commented Feb 8, 2018

@jeroenmeulenaar Do you mind upgrading to:

python --version
Python 3.6.3

As I could not reproduce this on 3.6.3 . And all tests are passing as well with this import statement as you can see here:

from bunq.sdk import context

So, if this has to do with python 3.4.2, then we must either increase the minimum required python version, or find out why it doesn't work on that version.

@jeroenmeulenaar
Copy link
Author

jeroenmeulenaar commented Feb 9, 2018

@OGKevin I'd like not to upgrade, as I like to stay on Debian stable.

I think I can workaround this by changing the offending import

from json import JSONDecodeError

to

from simplejson import JSONDecodeError

I don't know enough about the differences between json and simplejson to know if this is okay...

I also run into a new issue: #73. If it's really needed I can look into upgrading python, but I'd like to understand it first...

@OGKevin
Copy link
Contributor

OGKevin commented Feb 9, 2018

@jeroenmeulenaar I could reproduce this indeed on python 3.4.2 I have a felling that to solve this we would need to restructure a majority of the project 🤦‍♂️.

So we have 2 options, increase the minimum required python version or see if we can make it backward compatible.

I think if we dive into the change logs of python we could find out why it works on 3.6 and not on 3.4.

Cant you use pyenv on debian stable ?

@jeroenmeulenaar
Copy link
Author

jeroenmeulenaar commented Feb 9, 2018

@OGKevin Here is the original python issue: https://bugs.python.org/issue19361, from https://docs.python.org/3/whatsnew/3.5.html.

I think it could it be solved by changing

except JSONDecodeError:

to except ValueError, since JSONDecodeError is a subclass of ValueError. It doesn't look like you use the added functionality of JSONDecodeError anyway :)

And yes, I could workaround it (pyenv, or making my own fork), but maybe others hit this issue as well. Debian stable is not very up-to-date, but it's very stable :)

@OGKevin
Copy link
Contributor

OGKevin commented Feb 12, 2018

@jeroenmeulenaar I see, do you mind making a PR if you think you have fixed it ? If not ill look into it, but that will take some time I have a lot on my list ATM. We will include it in the 0.13.0 release

@OGKevin OGKevin self-assigned this Feb 12, 2018
@OGKevin OGKevin added the bug label Feb 12, 2018
@OGKevin OGKevin added this to the 0.13.0 milestone Feb 12, 2018
@OGKevin OGKevin added this to To do in 1.0.0 - SDK Mar 21, 2018
@OGKevin OGKevin modified the milestones: 0.13.0, 0.13.5 Mar 27, 2018
@OGKevin OGKevin moved this from To do to pending review in 1.0.0 - SDK Apr 8, 2018
OGKevin added a commit that referenced this issue Apr 12, 2018
…k_python#72

Use ValueError isntead of JsonDecodeError. (#72)
@OGKevin OGKevin closed this as completed Apr 12, 2018
1.0.0 - SDK automation moved this from pending review to Done Apr 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
1.0.0 - SDK
  
Done
Development

No branches or pull requests

2 participants