# Buggy code
def parse_response(self, response):
    p, u = self.getparser()

    response_body = ""

    while True:
        data = response.read(1024)
        if not data:
            break
        response_body += data

    if self.verbose:
        log.info("body: %s", repr(response_body))

    # Remove SCGI headers from the response.
    _, response_body = re.split(r"\n\s*?\n", response_body, maxsplit=1)
    p.feed(response_body)
    p.close()

    return u.close()


# Traceback (UnicodeDecodeError)
2017-02-17 10:37 VERBOSE  task          hdp             REJECTED: `Hacksaw Ridge 2016 1080p BluRay TrueHD Atmos 7.1 x264-PbK` by seen plugin because entry with url `http://www.hdpter.net/download.php?id=10438&amp;passkey=ab0ee1ba02ec1f4cd892219cab827967` is already marked seen in the task hdp at 2017-02-12 22:03
2017-02-17 10:37 VERBOSE  task          hdp             ACCEPTED: `Al final del túnel AKA At the End of the Tunnel 2016 1080p BluRay TrueHD 5.1 x264-PbK` by accept_all plugin
2017-02-17 10:37 INFO     download      hdp             Downloading: Al final del túnel AKA At the End of the Tunnel 2016 1080p BluRay TrueHD 5.1 x264-PbK
2017-02-17 10:37 VERBOSE  details       hdp             Summary - Accepted: 1 (Rejected: 9 Undecided: 0 Failed: 0)
2017-02-17 10:37 CRITICAL task          hdp             BUG: Unhandled error in plugin rtorrent: 'ascii' codec can't decode byte 0xc3 in position 333: ordinal not in range(128)
Traceback (most recent call last):
File "/home/xiayu/CODE/PYTHON/flexget/lib/python2.7/site-packages/flexget/task.py", line 483, in __run_plugin
return method(*args, **kwargs)
File "/home/xiayu/CODE/PYTHON/flexget/lib/python2.7/site-packages/flexget/event.py", line 23, in __call__
return self.func(*args, **kwargs)
File "/home/xiayu/CODE/PYTHON/flexget/lib/python2.7/site-packages/flexget/plugins/clients/rtorrent.py", line 531, in on_task_output
self.add_entry(client, entry, options, start=config['start'], mkdir=config['mkdir'])
File "/home/xiayu/CODE/PYTHON/flexget/lib/python2.7/site-packages/flexget/plugins/clients/rtorrent.py", line 639, in add_entry
if client.torrent(entry['torrent_info_hash']):
File "/home/xiayu/CODE/PYTHON/flexget/lib/python2.7/site-packages/flexget/plugins/clients/rtorrent.py", line 356, in torrent
resp = multi_call()
File "/usr/lib64/python2.7/xmlrpclib.py", line 1006, in __call__
return MultiCallIterator(self.__server.system.multicall(marshalled_list))
File "/home/xiayu/CODE/PYTHON/flexget/lib/python2.7/site-packages/flexget/plugins/clients/rtorrent.py", line 38, in __call__
return self.__send(self.__name, args)
File "/home/xiayu/CODE/PYTHON/flexget/lib/python2.7/site-packages/flexget/plugins/clients/rtorrent.py", line 192, in __request
verbose=self.__verbose
File "/home/xiayu/CODE/PYTHON/flexget/lib/python2.7/site-packages/flexget/plugins/clients/rtorrent.py", line 106, in request
return self.single_request(host, handler, request_body, verbose)
File "/home/xiayu/CODE/PYTHON/flexget/lib/python2.7/site-packages/flexget/plugins/clients/rtorrent.py", line 134, in single_request
return self.parse_response(sock.makefile())
File "/home/xiayu/CODE/PYTHON/flexget/lib/python2.7/site-packages/flexget/plugins/clients/rtorrent.py", line 148, in parse_response
response_body += data
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 333: ordinal not in range(128)

# Fixed code
def parse_response(self, response):
    p, u = self.getparser()

    response_body = ""

    while True:
        data = response.read(1024)
        if not data:
            break
        response_body += native_str_to_text(data, encoding="utf-8")

    if self.verbose:
        log.info("body: %s", repr(response_body))

    # Remove SCGI headers from the response.
    _, response_body = re.split(r"\n\s*?\n", response_body, maxsplit=1)
    p.feed(response_body.encode("utf-8"))
    p.close()

    return u.close()