Skip to content

Commit

Permalink
Py3: do not use iter* methods with dict
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinBasti committed Jul 2, 2016
1 parent bfd6175 commit 3bf36f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
15 changes: 12 additions & 3 deletions dns/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
from ._compat import string_types, text_type


_py3 = sys.version_info > (3,)


class BadZone(dns.exception.DNSException):

"""The DNS zone is malformed."""
Expand Down Expand Up @@ -150,16 +153,22 @@ def __delitem__(self, key):
del self.nodes[key]

def __iter__(self):
return self.nodes.iterkeys()
return self.nodes.__iter__()

def iterkeys(self):
return self.nodes.iterkeys()
if _py3:
return self.nodes.keys()
else:
return self.nodes.iterkeys() # pylint: disable=dict-iter-method

def keys(self):
return self.nodes.keys()

def itervalues(self):
return self.nodes.itervalues()
if _py3:
return self.nodes.values()
else:
return self.nodes.itervalues() # pylint: disable=dict-iter-method

def values(self):
return self.nodes.values()
Expand Down
1 change: 0 additions & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ disable=
bad-continuation,
bare-except,
deprecated-method,
dict-iter-method,
fixme,
getslice-method,
global-statement,
Expand Down

0 comments on commit 3bf36f7

Please sign in to comment.