def _wsgiString(string):  # Python 2.
        """
        Convert C{string} to an ISO-8859-1 byte string, if it is not already.

        @type string: C{str}/C{bytes} or C{unicode}
        @rtype: C{str}/C{bytes}

        @raise UnicodeEncodeError: If C{string} contains non-ISO-8859-1 chars.
        """
        if isinstance(string, str):
            return string
        else:
            return string.encode('iso-8859-1')

        Convert C{string} to an ISO-8859-1 byte string, if it is not already.

        @type string: C{str}/C{bytes} or C{unicode}
        @rtype: C{str}/C{bytes}

        @raise UnicodeEncodeError: If C{string} contains non-ISO-8859-1 chars.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/wsgi.py