# Buggy code
def update_pages(self, new_download=False):
    if self.current_download is None:
        return

    self.window().download_progress_bar.update_with_download(self.current_download)
    self.window().download_detail_name_label.setText(self.current_download["name"])
    self.window().download_detail_status_label.setText(
        DLSTATUS_STRINGS[eval(self.current_download["status"])]
    )
    self.window().download_detail_filesize_label.setText(
        "%s in %d files"
        % (
            format_size(float(self.current_download["size"])),
            len(self.current_download["files"]),
        )
    )
    self.window().download_detail_health_label.setText(
        "%d seeders, %d leechers"
        % (self.current_download["num_seeds"], self.current_download["num_peers"])
    )
    self.window().download_detail_infohash_label.setText(
        self.current_download["infohash"]
    )
    self.window().download_detail_destination_label.setText(
        self.current_download["destination"]
    )
    self.window().download_detail_availability_label.setText(
        "%.2f" % self.current_download["availability"]
    )

    if (
        new_download
    ):  # When we have a new download, clear all pages and draw new widgets
        # Populate the files list
        self.window().download_files_list.clear()
        self.files_widgets = {}
        for dfile in self.current_download["files"]:
            item = QTreeWidgetItem(self.window().download_files_list)
            DownloadsDetailsTabWidget.update_file_row(item, dfile)
            self.files_widgets[dfile["name"]] = item

    else:  # No new download, just update data in the lists
        for dfile in self.current_download["files"]:
            DownloadsDetailsTabWidget.update_file_row(
                self.files_widgets[dfile["name"]], dfile
            )

    # Populate the trackers list
    self.window().download_trackers_list.clear()
    for tracker in self.current_download["trackers"]:
        item = QTreeWidgetItem(self.window().download_trackers_list)
        DownloadsDetailsTabWidget.update_tracker_row(item, tracker)
        self.tracker_widgets[tracker["url"]] = item

    # Populate the peers list if the peer information is available
    self.window().download_peers_list.clear()
    if "peers" in self.current_download:
        for peer in self.current_download["peers"]:
            item = QTreeWidgetItem(self.window().download_peers_list)
            DownloadsDetailsTabWidget.update_peer_row(item, peer)


# Traceback (RuntimeError)
Traceback (most recent call last):
File "/usr/share/tribler/TriblerGUI/event_request_manager.py", line 91, in on_read_data
raise RuntimeError(json_dict["event"]["text"])
RuntimeError: Unhandled Error
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 101, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 84, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
return func(*args,**kw)
--- <exception caught here> ---
File "/usr/lib/python2.7/dist-packages/twisted/internet/selectreactor.py", line 149, in _doReadOrWrite
why = getattr(selectable, method)()
File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 208, in doRead
return self._dataReceived(data)
File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 214, in _dataReceived
rval = self.protocol.dataReceived(data)
File "/usr/share/tribler/Tribler/community/tunnel/Socks5/server.py", line 114, in dataReceived
if not self._try_request():
File "/usr/share/tribler/Tribler/community/tunnel/Socks5/server.py", line 169, in _try_request
offset, request = conversion.decode_request(0, self.buffer)
File "/usr/share/tribler/Tribler/community/tunnel/Socks5/conversion.py", line 174, in decode_request
offset, destination_address = __decode_address(address_type, offset, data)
File "/usr/share/tribler/Tribler/community/tunnel/Socks5/conversion.py", line 149, in __decode_address
raise ValueError("Unsupported address type %r" % address_type )
exceptions.ValueError: Unsupported address type 5

# Fixed code
def update_pages(self, new_download=False):
    if self.current_download is None:
        return

    self.window().download_progress_bar.update_with_download(self.current_download)
    self.window().download_detail_name_label.setText(self.current_download["name"])
    self.window().download_detail_status_label.setText(
        DLSTATUS_STRINGS[eval(self.current_download["status"])]
    )
    self.window().download_detail_filesize_label.setText(
        "%s in %d files"
        % (
            format_size(float(self.current_download["size"])),
            len(self.current_download["files"]),
        )
    )
    self.window().download_detail_health_label.setText(
        "%d seeders, %d leechers"
        % (self.current_download["num_seeds"], self.current_download["num_peers"])
    )
    self.window().download_detail_infohash_label.setText(
        self.current_download["infohash"]
    )
    self.window().download_detail_destination_label.setText(
        self.current_download["destination"]
    )
    self.window().download_detail_availability_label.setText(
        "%.2f" % self.current_download["availability"]
    )

    if new_download or len(self.current_download["files"]) != len(
        self.files_widgets.keys()
    ):
        # (re)populate the files list
        self.window().download_files_list.clear()
        self.files_widgets = {}
        for dfile in self.current_download["files"]:
            item = QTreeWidgetItem(self.window().download_files_list)
            DownloadsDetailsTabWidget.update_file_row(item, dfile)
            self.files_widgets[dfile["name"]] = item

    else:  # No new download, just update data in the lists
        for dfile in self.current_download["files"]:
            DownloadsDetailsTabWidget.update_file_row(
                self.files_widgets[dfile["name"]], dfile
            )

    # Populate the trackers list
    self.window().download_trackers_list.clear()
    for tracker in self.current_download["trackers"]:
        item = QTreeWidgetItem(self.window().download_trackers_list)
        DownloadsDetailsTabWidget.update_tracker_row(item, tracker)

    # Populate the peers list if the peer information is available
    self.window().download_peers_list.clear()
    if "peers" in self.current_download:
        for peer in self.current_download["peers"]:
            item = QTreeWidgetItem(self.window().download_peers_list)
            DownloadsDetailsTabWidget.update_peer_row(item, peer)