Commits

Andrew Godwin  committed e2c9102 Merge

Merged in gdub/south/python3-iteritems (pull request #162)

Fixed a Python 3 incompatibility by replacing dict.iteritems() usage with an iteritems py3 util function from six.

  • Participants
  • Parent commits f22b820, 3753b49

Comments (0)

Files changed (2)

File south/migration/migrators.py

 from south.db import DEFAULT_DB_ALIAS
 from south.models import MigrationHistory
 from south.signals import ran_migration
-from south.utils.py3 import StringIO
+from south.utils.py3 import StringIO, iteritems
 
 
 class Migrator(object):
             if self.verbosity:
                 print(" - Migration '%s' is marked for no-dry-run." % migration)
             return
-        for name, db in south.db.dbs.iteritems():
+        for name, db in iteritems(south.db.dbs):
             south.db.dbs[name].dry_run = True
         # preserve the constraint cache as it can be mutated by the dry run
         constraint_cache = deepcopy(south.db.db._constraint_cache)
             if self._ignore_fail:
                 south.db.db.debug = old_debug
             south.db.db.clear_run_data(pending_creates)
-            for name, db in south.db.dbs.iteritems():
+            for name, db in iteritems(south.db.dbs):
                 south.db.dbs[name].dry_run = False
             # restore the preserved constraint cache from before dry run was
             # executed

File south/utils/py3.py

 def with_metaclass(meta, base=object):
     """Create a base class with a metaclass."""
     return meta("NewBase", (base,), {})
+
+
+def _add_doc(func, doc):
+    """Add documentation to a function."""
+    func.__doc__ = doc
+
+if PY3:
+    def iteritems(d, **kw):
+        return iter(d.items(**kw))
+else:
+    def iteritems(d, **kw):
+        return iter(d.iteritems(**kw))
+
+_add_doc(iteritems,
+         "Return an iterator over the (key, value) pairs of a dictionary.")