Skip to content

change SortedDict to OrderedDict + fix list and tuple concatination #2858

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

Merged
merged 13 commits into from
Apr 27, 2015

Conversation

kazmiruk
Copy link

I need to support django-rest-framework on django 1.8 a little bit more, but there are some errors and irritating warnings. This PR fixes error and changes deprecated SortedDict to OrderedDict (as I seen you are not using something special from SortedDict which not compatible with OrderedDict)

@xordoquy
Copy link
Collaborator

Unfortunately the tests don't pass.

@kazmiruk
Copy link
Author

Yes, sorry. I was not careful. Now all tests pass.

@jpadilla
Copy link
Member

@kazmiruk as a general note all compatibility checks should go in compat.py. Everywhere that's used just import from the compat module. As it stands currently there's a lot of duplicate checks in different modules which makes maintainability harder. Consolidating those in the compat module help us a ton. Other than that, looks good to me. Thanks!

@kazmiruk
Copy link
Author

Yes, it makes sense. Done.

try:
from collections import OrderedDict
except ImportError:
from django.utils.datastructures import SortedDict as OrderedDict
Copy link
Member

Choose a reason for hiding this comment

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

Let's import these from compat instead.

@tomchristie
Copy link
Member

Couple of inline comments, but otherwise this is looking good!

@tomchristie tomchristie added this to the 3.1.2 Release milestone Apr 23, 2015
@@ -985,13 +992,16 @@ def restore_object(self, attrs, instance=None):
if field_name in attrs:
m2m_data[field_name] = attrs.pop(field_name)

# Forward m2m relations
for field in meta.many_to_many + meta.virtual_fields:
def _inner_loop_code(field):
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused about this - what's going on here, and should this really be part of the same pull request as the SortedDict/OrderedDict change?

@kazmiruk
Copy link
Author

Yes, I'm sorry that I didn't create separate branches for each fix. About meta.many_to_many + meta.virtual_fields in django 1.8 those properties has different type (list and tupple). This causes to exception when concatenates.

@jpadilla
Copy link
Member

I still think this should be two different pull requests, one for the compat changes and another for list/tuple concat changes.

@kazmiruk
Copy link
Author

I think it's better just exclude list\tuple changes from this PR. #2857 about list\tuple changes

@tomchristie
Copy link
Member

Looks good - thanks!

tomchristie added a commit that referenced this pull request Apr 27, 2015
change SortedDict to OrderedDict + fix list and tuple concatination
@tomchristie tomchristie merged commit 91ba271 into encode:version-2.4.x Apr 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants