PY3K: use six for StringIO
PY3K: six.iteritems