Skip to content

Commit

Permalink
Merge pull request #53 from Mobeye/python3-compat
Browse files Browse the repository at this point in the history
Fix issue #52 python 2-3 compatibility
  • Loading branch information
mattrobenolt committed Jan 19, 2015
2 parents 2c864e0 + acb9b49 commit ff2e97f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion bitfield/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import six

from django.db.models import F
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
Expand All @@ -22,7 +24,7 @@ def __init__(self, field, request, params, model, model_admin, field_path):
field, request, params, model, model_admin, field_path)

def queryset(self, request, queryset):
filter = dict((p, bitor(F(p), v)) for p, v in self.used_parameters.iteritems())
filter = dict((p, bitor(F(p), v)) for p, v in six.iteritems(self.used_parameters))
try:
return queryset.filter(**filter)
except ValidationError as e:
Expand Down
5 changes: 4 additions & 1 deletion bitfield/types.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from six import string_types


class Bit(object):
"""
Represents a single Bit.
Expand Down Expand Up @@ -229,7 +232,7 @@ def iteritems(self):
yield (k, getattr(self, k).is_set)

def get_label(self, flag):
if isinstance(flag, basestring):
if isinstance(flag, string_types):
flag = self._keys.index(flag)
if isinstance(flag, Bit):
flag = flag.number
Expand Down

0 comments on commit ff2e97f

Please sign in to comment.