disqus/django-bitfield — pull request #49 by nessita (2014-09-28 20:43:29+00:00)
Title: Ensure total ordering for the BitHandler (Python3 compat).

Hello,

This pull request ensure Python3 compatibility for django-bitfield. I'm currently using the bitfield in a project of mine that requires django 1.7 and Python 3.4.

The current bitfield implementation does not work on Python3 since whe submitting a form with a bitfield in it the following exception is raised:

unorderable types: BitHandler() < int()

This is caused because __cmp__ is gone in Python3, for references see[0]:

"""The cmp() function should be treated as gone, and the __cmp__() special method is no longer supported. Use __lt__() for sorting, __eq__() with __hash__(), and other rich comparisons as needed. (If you really need the cmp() functionality, you could use the expression (a > b) - (a < b) as the equivalent for cmp(a, b).)"""

Thanks.

[0] https://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons