'Return an iterator that returns the next field in a ``(marker, value)``
tuple, where ``marker`` and ``value`` are unicode strings if an ``encoding``
was specified in the ``fields()`` method. Otherwise they are non-unicode strings.
:param strip: strip trailing whitespace from the last line of each field
:type strip: bool
:param unwrap: Convert newlines in a field to spaces.
:type unwrap: bool
:param encoding: Name of an encoding to use. If it is specified then
the ``fields()`` method returns unicode strings rather than non
unicode strings.
:type encoding: str or None
:param errors: Error handling scheme for codec. Same as the ``decode()``
builtin string method.
:type errors: str
:param unicode_fields: Set of marker names whose values are UTF-8 encoded.
Ignored if encoding is None. If the whole file is UTF-8 encoded set
``encoding=\'utf8\'`` and leave ``unicode_fields`` with its default
value of None.
:type unicode_fields: sequence
:rtype: iter(tuple(str, str))'

def fields(self, strip=True, unwrap=True, encoding=None, errors='strict', unicode_fields=None):

    if ((encoding is None) and (unicode_fields is not None)):
        raise ValueError('unicode_fields    is    set    but    not    encoding.')
    unwrap_pat = re.compile('\\n+')
    for (mkr, val) in self.raw_fields():
        if (encoding and (not PY3)):
            if ((unicode_fields is not None) and (mkr in unicode_fields)):
                val = val.decode('utf8', errors)
            else:
                val = val.decode(encoding, errors)
            mkr = mkr.decode(encoding, errors)
        if unwrap:
            val = unwrap_pat.sub('    ', val)
        if strip:
            val = val.rstrip()
        (yield (mkr, val))
