Skip to content

Commit

Permalink
Python 3 compatibility continues.
Browse files Browse the repository at this point in the history
  • Loading branch information
shakefu committed Aug 4, 2015
1 parent 93780ad commit d9d87ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pytool/lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ class _UNSETMeta(type):
def __nonzero__(cls):
return False

def __bool__(cls):
# Python 3
return False

def __len__(cls):
return 0

Expand All @@ -219,6 +223,9 @@ def __iter__(cls):
def next(cls):
raise StopIteration()

# Python 3
__next__ = next

def __repr__(cls):
return 'UNSET'

Expand Down Expand Up @@ -348,6 +355,10 @@ def __contains__(self, name):
def __nonzero__(self):
return bool(self.__dict__)

def __bool__(self):
# For Python 3
return bool(self.__dict__)

def iteritems(self, base_name=None):
""" Return iterator which returns ``(key, value)`` tuples.
Expand Down
2 changes: 2 additions & 0 deletions test/test_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def test_list_proxy_proxies_comparisons():


def test_list_proxy_comparison_operator():
if six.PY3:
raise SkipTest('Python 2')
l = [1, 2]
a = [1, 2]
b = [3, 4]
Expand Down

0 comments on commit d9d87ce

Please sign in to comment.