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

Python 3.5 support #81

Closed
wants to merge 4 commits into from
Closed

Conversation

tochev
Copy link
Contributor

@tochev tochev commented Aug 21, 2016

Closes #80

@blodone
Copy link

blodone commented Sep 2, 2016

+1

@XavierCLL
Copy link

+1 for merge

@askpatrickw
Copy link

Is there anything we can do to help with getting this merged?

@askpatrickw
Copy link

AS another data point:
I confirmed on my own application that with Master of this repro + @tochev 's changes it fixed my issue.

@decentral1se
Copy link

Any chance this can get into master? Need it big time. Thanks.

if not needs_class_hack:
# restore FLOAT_REPR
json.encoder.FLOAT_REPR = original_float_repr

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does all this code come from?

If it was written specifically for django-geojson then each aspect of it deserves extensive tests...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As explained in the comments the code is copied from the python3.5 source code ( https://github.com/python/cpython/blob/3.5/Lib/json/encoder.py#L203 ) and thing that is actually changed is def floatstr(..., _repr=float_repr, ...) instead of def floatstr(..., _repr=float.__repr__, ...). The rest of the modifications are prepending json.encoder. where needed.

Btw since python3.6 has been released and the encoder code is the same ( https://github.com/python/cpython/blob/3.6/Lib/json/encoder.py#L204 ) needs_class_hack should be (3, 5) <= sys.version_info < (3, 7)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did it differently so it works anywhere: c70a7e4

Copy link
Contributor Author

@tochev tochev Feb 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gagaro I didn't do it your way because I copied a chunk of internal code from the original python class and in the unlikely case that this logic is changed in python3.7, in with my solution it would crash (the tests would fail) and somebody would have to manually inspect it, while in yours it will work, but might sometimes create strange results that would be harder to debug.

Anyway, thanks, glad to see it added to the master :)

@leplatrem
Copy link
Collaborator

BTW we can't merge pull requests with broken tests :)

@Gagaro
Copy link
Member

Gagaro commented Feb 28, 2017

Test were broken on master. I just fixed them. Could you rebase? Thanks 👍 .

(Actually they are still broken because I added test for python 3.5, the test should be green with your PR).

@Gagaro
Copy link
Member

Gagaro commented Feb 28, 2017

@Gagaro
Copy link
Member

Gagaro commented Feb 28, 2017

Merged on master, I'll release as soon as I have the rights on pypi. Thanks 👍 .

@Gagaro
Copy link
Member

Gagaro commented Feb 28, 2017

django-geojson 2.10.0 is out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants