-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
compat: handle SyntaxError when importing simplejson #2064
compat: handle SyntaxError when importing simplejson #2064
Conversation
We officially support Python 2.6 to 3.3, but simplejson does not support Python 3.1 or 3.2: simplejson/simplejson#66 Importing simplejson on Python 3.2 results in a SyntaxError because simplejson uses the u'...' syntax (the syntax was not supported in Python 3.0 to 3.2). Support for loading simplejson instead of the stdlib json module was added by #710: https://github.com/kennethreitz/requests/pull/710 No mention was made of the lack of support for Python 3.2, but it was mentioned that simplejson can be faster than the stdlib json module.
Thanks, this looks good to me! 🍰 I'm not 100% sure it'll get merged, we may drop support for 3.2 soon, but if we don't we'll merge it. |
I ran into this for a project of mine where we try to support Python 3.2. However, it also affects much more significant projects, in particular So I would suggest not dropping support for 3.2 before |
The error for
This will fail to compile the C extension, but
|
Well, that's a pain in the neck. Seems like a good idea though, and seeing as |
Cool, thanks for looking at it! |
My first attempt at solving this was to reverse the imports, that is try In my own projects (for Python 2.6+) I've always just imported json and let that be good enough. |
Either way y'all are right that it's better to have this than to not. It doesn't increase the complexity of the code and if anything the simplejson maintainers should be scolded for not supporting 3.2 :P. I'm 👍 |
3.2 is important, 3.1 is not. |
Python version 3.0 to 3.2 had no support for u'...' Unicode literals. The support was added again in Python 3.3 to make it easier to port code from Python 2.x. The lack of u'...' support has not been a direct problem for us, we would like to use python-swiftclient instead of our own miniswift module (zerovm#31). However, python-swiftclient only supports Python 3.3 and later. More precisely, python-swiftclient tries to import simplejson and this fails with a SyntaxError on Python 3.2. The simplejson project will probably not support Python 3.2 anytime soon: simplejson/simplejson#66 We will therefore also drop support for Python 3.2 for now. We will work with the upstream projects to see if it is easy to restore Python 3.2 support. The first pull request for one of our dependencies has been positively received: https://github.com/kennethreitz/requests/pull/2064 Pip is also affected by this problem and an issue has been created: pypa/pip#1839
This looks like a great change. |
compat: handle SyntaxError when importing simplejson
We officially support Python 2.6 to 3.3, but simplejson does not
support Python 3.1 or 3.2:
simplejson/simplejson#66
Importing simplejson on Python 3.2 results in a SyntaxError because
simplejson uses the u'...' syntax (the syntax was not supported in
Python 3.0 to 3.2).
Support for loading simplejson instead of the stdlib json module was
added by #710:
https://github.com/kennethreitz/requests/pull/710
No mention was made of the lack of support for Python 3.2, but it was
mentioned that simplejson can be faster than the stdlib json module.