Use "six" to abstract dictionary iteration and callable for python 2/3

Review Request #4893 — Created Nov. 4, 2013 and submitted

Information

Djblets
master

Reviewers

Use "six" to abstract dictionary iteration and callable for python 2/3

I'm starting to work on porting our codebase to be compatible with both python
2 and 3. In python 3, items(), keys(), and values() are all iterators by
default and the old iter*() methods are gone. The "six" library includes
abstractions to handle these.

In addition, for some strange reason 'callable' is gone in python 3.0 and 3.1.
They brought it back in 3.2 (which may be a reasonable minimum), but for now,
to get the 2to3 tool to shut up, I'm using six's abstraction for that as well.

  • Ran djblets unit tests
  • Ran reviewboard unit tests
Description From Last Updated

That ordering doesn't seem right. I think the from made sense where it was.

chipx86chipx86

Just for my own knowledge, why is this change needed? I thought sorted() allowed an iterator.

chipx86chipx86

We should probably just use self.get_enabled_extensions() here.

chipx86chipx86

Should use self.get_installed_extensions.

chipx86chipx86
chipx86
  1. This library is going to take some getting used to.

  2. djblets/extensions/tests.py (Diff revision 1)
     
     
     
     
     
     

    That ordering doesn't seem right. I think the from made sense where it was.

    1. Oops! For some reason I read that and skipped the "from mock" part and thought it was a normal import. Weird.

  3. djblets/log/middleware.py (Diff revision 1)
     
     

    Just for my own knowledge, why is this change needed? I thought sorted() allowed an iterator.

    1. It's not. fixing.

  4. 
      
chipx86
  1. Can we use the Django-provided version of six, instead of adding another dependency?

    1. I had meant to and then I spazzed. Fixing.
  2. 
      
david
chipx86
  1. 
      
  2. djblets/extensions/manager.py (Diff revision 2)
     
     

    We should probably just use self.get_enabled_extensions() here.

  3. djblets/extensions/manager.py (Diff revision 2)
     
     

    Should use self.get_installed_extensions.

  4. 
      
david
david
Review request changed

Status: Closed (submitted)

Loading...