*.py: Hack around the mapping change from `itervalues' to just `values', etc.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 21 Oct 2019 17:13:57 +0000 (18:13 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 11 Apr 2020 11:44:21 +0000 (12:44 +0100)
This change is only about accessing existing mappings.  We'll have to
set up our own mappings the hard way.

catacomb/__init__.py
catacomb/pwsafe.py

index bbbe74b..24c96e0 100644 (file)
@@ -80,6 +80,10 @@ lostexchook = default_lostexchook
 ## Text/binary conversions.
 def _bin(s): return s
 
+## Iterating over dictionaries.
+def _iteritems(dict): return dict.iteritems()
+def _itervalues(dict): return dict.itervalues()
+
 ## How to fix a name back into the right identifier.  Alas, the rules are not
 ## consistent.
 def _fixname(name):
@@ -103,9 +107,9 @@ def _init():
     if i[0] != '_':
       d[i] = b[i];
   for i in [gcciphers, gcaeads, gchashes, gcmacs, gcprps]:
-    for c in i.itervalues():
+    for c in _itervalues(i):
       d[_fixname(c.name)] = c
-  for c in gccrands.itervalues():
+  for c in _itervalues(gccrands):
     d[_fixname(c.name + 'rand')] = c
 _init()
 
@@ -657,11 +661,11 @@ _augment(Key, _tmp)
 class _tmp:
   def __repr__(me):
     return '%s({%s})' % (_clsname(me),
-                         ', '.join(['%r: %r' % kv for kv in me.iteritems()]))
+                         ', '.join(['%r: %r' % kv for kv in _iteritems(me)()]))
   def _repr_pretty_(me, pp, cyclep):
     ind = _pp_bgroup_tyname(pp, me)
     if cyclep: pp.text('...')
-    else: _pp_dict(pp, me.iteritems())
+    else: _pp_dict(pp, _iteritems(me))
     pp.end_group(ind, ')')
 _augment(KeyAttributes, _tmp)
 
@@ -705,11 +709,11 @@ _augment(KeyDataECPt, _tmp)
 class _tmp:
   def __repr__(me):
     return '%s({%s})' % (_clsname(me),
-                         ', '.join(['%r: %r' % kv for kv in me.iteritems()]))
+                         ', '.join(['%r: %r' % kv for kv in _iteritems(me)]))
   def _repr_pretty_(me, pp, cyclep):
     ind = _pp_bgroup_tyname(pp, me, '({ ')
     if cyclep: pp.text('...')
-    else: _pp_dict(pp, me.iteritems())
+    else: _pp_dict(pp, _iteritems(me))
     pp.end_group(ind, ' })')
 _augment(KeyDataStructured, _tmp)
 
@@ -1009,11 +1013,11 @@ class Ed448Priv (_EdDSAPriv, Ed448Pub):
 
 class _tmp:
   def __repr__(me):
-    return '{%s}' % ', '.join(['%r: %r' % kv for kv in me.iteritems()])
+    return '{%s}' % ', '.join(['%r: %r' % kv for kv in _iteritems(me)])
   def _repr_pretty_(me, pp, cyclep):
     ind = _pp_bgroup(pp, '{ ')
     if cyclep: pp.text('...')
-    else: _pp_dict(pp, me.iteritems())
+    else: _pp_dict(pp, _iteritems(me))
     pp.end_group(ind, ' }')
 _augment(_base._MiscTable, _tmp)
 
index 6d949c5..6874ae8 100644 (file)
@@ -37,6 +37,10 @@ import catacomb as _C
 ###--------------------------------------------------------------------------
 ### Python version portability.
 
+def _iterkeys(dict): return dict.iterkeys()
+def _itervalues(dict): return dict.itervalues()
+def _iteritems(dict): return dict.iteritems()
+
 def _bin(text): return text
 def _text(bin): return bin
 
@@ -320,7 +324,7 @@ class StorageBackend (object):
   @staticmethod
   def classes():
     """Return an iterator over the concrete subclasses."""
-    return StorageBackend.CLASSES.itervalues()
+    return _itervalues(StorageBackend.CLASSES)
 
   @staticmethod
   def open(file, writep = False):
@@ -801,7 +805,7 @@ class PlainTextBackend (StorageBackend):
   def _write_meta(me, f, prefix = ''):
     """Write the metadata records to F, each with the given PREFIX."""
     f.write('\n## Metadata.\n')
-    for k, v in me._meta.iteritems():
+    for k, v in _iteritems(me._meta):
       f.write('%s%s=%s\n' % (prefix, _enc_metaname(k), _enc_metaval(v)))
 
   def _get_meta(me, name, default):
@@ -813,7 +817,7 @@ class PlainTextBackend (StorageBackend):
     me._mark_dirty()
     del me._meta[name]
   def _iter_meta(me):
-    return me._meta.iteritems()
+    return _iteritems(me._meta)
 
   def _parse_passwd(me, line):
     """Parse LINE as a password LABEL=PAYLOAD pair, and updates `_pw'."""
@@ -823,7 +827,7 @@ class PlainTextBackend (StorageBackend):
   def _write_passwd(me, f, prefix = ''):
     """Write the password records to F, each with the given PREFIX."""
     f.write('\n## Password data.\n')
-    for k, v in me._pw.iteritems():
+    for k, v in _iteritems(me._pw):
       f.write('%s%s=%s\n' % (prefix, _b64(k), _b64(v)))
 
   def _get_passwd(me, label):
@@ -835,7 +839,7 @@ class PlainTextBackend (StorageBackend):
     me._mark_dirty()
     del me._pw[str(label)]
   def _iter_passwds(me):
-    return me._pw.iteritems()
+    return _iteritems(me._pw)
 
 class FlatFileStorageBackend (PlainTextBackend):
   """