partly revert 7470: Upgrade to db version 17 fails in Python3 due to use of iteritems

This commit is contained in:
Paul Franklin 2014-03-01 16:44:28 -08:00
parent c0ffe802bd
commit 19fc47b38d

View File

@ -398,6 +398,11 @@ class FlatNodeMap(object):
insert_pos = bisect.bisect_left(self._index2hndl, srtkey_hndl)
self._index2hndl.insert(insert_pos, srtkey_hndl)
#make sure the index map is updated
if sys.version_info[0] < 3: # keep this, for speed in Python2
for hndl, index in self._hndl2index.iteritems(): # in Python2 "if"
if index >= insert_pos:
self._hndl2index[hndl] += 1
else:
for hndl, index in self._hndl2index.items():
if index >= insert_pos:
self._hndl2index[hndl] += 1
@ -442,6 +447,11 @@ class FlatNodeMap(object):
if self._reverse:
self.__corr = (len(self._index2hndl) - 1, -1)
#update the handle2path map so it remains correct
if sys.version_info[0] < 3: # keep this, for speed in Python2
for key, val in self._hndl2index.iteritems(): # in Python2 "if"
if val > index:
self._hndl2index[key] -= 1
else:
for key, val in self._hndl2index.items():
if val > index:
self._hndl2index[key] -= 1