gurudesh/pytracebugs huggingface dataset:
# Buggy code
def on_transactions(self, transactions):
    for transaction in transactions["transactions"]:
        item = QTreeWidgetItem(self.window().wallet_transactions_list)
        item.setText(0, "Sent" if transaction["outgoing"] else "Received")
        item.setText(1, transaction["from"])
        item.setText(2, transaction["to"])
        item.setText(3, "%g %s" % (transaction["amount"], transaction["currency"]))
        item.setText(4, "%g %s" % (transaction["fee_amount"], transaction["currency"]))
        item.setText(5, transaction["id"])
        timestamp = (
            timestamp_to_time(float(transaction["timestamp"]))
            if transaction["timestamp"] != "False"
            else "-"
        )
        item.setText(6, timestamp)
        self.window().wallet_transactions_list.addTopLevelItem(item)


# Traceback (TypeError)
ERROR   1533554928.15            tribler_window:90   (root)  Traceback (most recent call last):
File "C:\Users\goqs\Documents\tribler\TriblerGUI\widgets\subscribedchannelspage.py", line 34, in received_subscribed_channels
if len(results['subscribed']) == 0:
TypeError: 'NoneType' object has no attribute '__getitem__'

# Fixed code
def on_transactions(self, transactions):
    if not transactions:
        return
    for transaction in transactions["transactions"]:
        item = QTreeWidgetItem(self.window().wallet_transactions_list)
        item.setText(0, "Sent" if transaction["outgoing"] else "Received")
        item.setText(1, transaction["from"])
        item.setText(2, transaction["to"])
        item.setText(3, "%g %s" % (transaction["amount"], transaction["currency"]))
        item.setText(4, "%g %s" % (transaction["fee_amount"], transaction["currency"]))
        item.setText(5, transaction["id"])
        timestamp = (
            timestamp_to_time(float(transaction["timestamp"]))
            if transaction["timestamp"] != "False"
            else "-"
        )
        item.setText(6, timestamp)
        self.window().wallet_transactions_list.addTopLevelItem(item)
# Buggy code
def on_wallet_created(self, response):
    if self.dialog:
        self.dialog.close_dialog()
        self.dialog = None
    self.load_wallets()


# Traceback (TypeError)
ERROR   1533554928.15            tribler_window:90   (root)  Traceback (most recent call last):
File "C:\Users\goqs\Documents\tribler\TriblerGUI\widgets\subscribedchannelspage.py", line 34, in received_subscribed_channels
if len(results['subscribed']) == 0:
TypeError: 'NoneType' object has no attribute '__getitem__'

# Fixed code
def on_wallet_created(self, response):
    if not response:
        return
    if self.dialog:
        self.dialog.close_dialog()
        self.dialog = None
    self.load_wallets()
# Buggy code
def on_emptying_tokens(self, data):
    json_data = json.dumps(data)

    if has_qr:
        self.empty_tokens_barcode_dialog = QWidget()
        self.empty_tokens_barcode_dialog.setWindowTitle(
            "Please scan the following QR code"
        )
        self.empty_tokens_barcode_dialog.setGeometry(10, 10, 500, 500)
        qr = qrcode.QRCode(
            version=1,
            error_correction=qrcode.constants.ERROR_CORRECT_M,
            box_size=10,
            border=5,
        )
        qr.add_data(json_data)
        qr.make(fit=True)

        img = qr.make_image()  # PIL format

        qim = ImageQt(img)
        pixmap = QtGui.QPixmap.fromImage(qim).scaled(
            600, 600, QtCore.Qt.KeepAspectRatio
        )
        label = QLabel(self.empty_tokens_barcode_dialog)
        label.setPixmap(pixmap)
        self.empty_tokens_barcode_dialog.resize(pixmap.width(), pixmap.height())
        self.empty_tokens_barcode_dialog.show()
    else:
        ConfirmationDialog.show_error(
            self.window(), DEPENDENCY_ERROR_TITLE, DEPENDENCY_ERROR_MESSAGE
        )


# Traceback (TypeError)
ERROR   1533554928.15            tribler_window:90   (root)  Traceback (most recent call last):
File "C:\Users\goqs\Documents\tribler\TriblerGUI\widgets\subscribedchannelspage.py", line 34, in received_subscribed_channels
if len(results['subscribed']) == 0:
TypeError: 'NoneType' object has no attribute '__getitem__'

# Fixed code
def on_emptying_tokens(self, data):
    if not data:
        return
    json_data = json.dumps(data)

    if has_qr:
        self.empty_tokens_barcode_dialog = QWidget()
        self.empty_tokens_barcode_dialog.setWindowTitle(
            "Please scan the following QR code"
        )
        self.empty_tokens_barcode_dialog.setGeometry(10, 10, 500, 500)
        qr = qrcode.QRCode(
            version=1,
            error_correction=qrcode.constants.ERROR_CORRECT_M,
            box_size=10,
            border=5,
        )
        qr.add_data(json_data)
        qr.make(fit=True)

        img = qr.make_image()  # PIL format

        qim = ImageQt(img)
        pixmap = QtGui.QPixmap.fromImage(qim).scaled(
            600, 600, QtCore.Qt.KeepAspectRatio
        )
        label = QLabel(self.empty_tokens_barcode_dialog)
        label.setPixmap(pixmap)
        self.empty_tokens_barcode_dialog.resize(pixmap.width(), pixmap.height())
        self.empty_tokens_barcode_dialog.show()
    else:
        ConfirmationDialog.show_error(
            self.window(), DEPENDENCY_ERROR_TITLE, DEPENDENCY_ERROR_MESSAGE
        )
# Buggy code
def on_settings_saved(self, _):
    # Now save the GUI settings
    self.window().gui_settings.setValue(
        "ask_download_settings", self.window().always_ask_location_checkbox.isChecked()
    )
    self.window().gui_settings.setValue(
        "use_monochrome_icon", self.window().use_monochrome_icon_checkbox.isChecked()
    )

    self.saved_dialog = ConfirmationDialog(
        TriblerRequestManager.window,
        "Settings saved",
        "Your settings have been saved.",
        [("CLOSE", BUTTON_TYPE_NORMAL)],
    )
    self.saved_dialog.button_clicked.connect(self.on_dialog_cancel_clicked)
    self.saved_dialog.show()
    self.window().fetch_settings()


# Traceback (TypeError)
ERROR   1533554928.15            tribler_window:90   (root)  Traceback (most recent call last):
File "C:\Users\goqs\Documents\tribler\TriblerGUI\widgets\subscribedchannelspage.py", line 34, in received_subscribed_channels
if len(results['subscribed']) == 0:
TypeError: 'NoneType' object has no attribute '__getitem__'

# Fixed code
def on_settings_saved(self, data):
    if not data:
        return
    # Now save the GUI settings
    self.window().gui_settings.setValue(
        "ask_download_settings", self.window().always_ask_location_checkbox.isChecked()
    )
    self.window().gui_settings.setValue(
        "use_monochrome_icon", self.window().use_monochrome_icon_checkbox.isChecked()
    )

    self.saved_dialog = ConfirmationDialog(
        TriblerRequestManager.window,
        "Settings saved",
        "Your settings have been saved.",
        [("CLOSE", BUTTON_TYPE_NORMAL)],
    )
    self.saved_dialog.button_clicked.connect(self.on_dialog_cancel_clicked)
    self.saved_dialog.show()
    self.window().fetch_settings()
# Buggy code
def received_subscribed_channels(self, results):
    self.window().subscribed_channels_list.set_data_items([])
    items = []

    if len(results["subscribed"]) == 0:
        self.window().subscribed_channels_list.set_data_items(
            [(LoadingListItem, "You are not subscribed to any channel.")]
        )
        return

    for result in results["subscribed"]:
        items.append((ChannelListItem, result))
    self.window().subscribed_channels_list.set_data_items(items)


# Traceback (TypeError)
ERROR   1533554928.15            tribler_window:90   (root)  Traceback (most recent call last):
File "C:\Users\goqs\Documents\tribler\TriblerGUI\widgets\subscribedchannelspage.py", line 34, in received_subscribed_channels
if len(results['subscribed']) == 0:
TypeError: 'NoneType' object has no attribute '__getitem__'

# Fixed code
def received_subscribed_channels(self, results):
    if not results:
        return
    self.window().subscribed_channels_list.set_data_items([])
    items = []

    if len(results["subscribed"]) == 0:
        self.window().subscribed_channels_list.set_data_items(
            [(LoadingListItem, "You are not subscribed to any channel.")]
        )
        return

    for result in results["subscribed"]:
        items.append((ChannelListItem, result))
    self.window().subscribed_channels_list.set_data_items(items)
# Buggy code
def on_channel_unsubscribed(self, json_result):
    if json_result["unsubscribed"]:
        self.unsubscribed_channel.emit(self.channel_info)
        self.channel_info["subscribed"] = False
        self.channel_info["votes"] -= 1
        self.update_subscribe_button()


# Traceback (TypeError)
ERROR   1533554928.15            tribler_window:90   (root)  Traceback (most recent call last):
File "C:\Users\goqs\Documents\tribler\TriblerGUI\widgets\subscribedchannelspage.py", line 34, in received_subscribed_channels
if len(results['subscribed']) == 0:
TypeError: 'NoneType' object has no attribute '__getitem__'

# Fixed code
def on_channel_unsubscribed(self, json_result):
    if not json_result:
        return
    if json_result["unsubscribed"]:
        self.unsubscribed_channel.emit(self.channel_info)
        self.channel_info["subscribed"] = False
        self.channel_info["votes"] -= 1
        self.update_subscribe_button()
# Buggy code
def on_channel_subscribed(self, json_result):
    if json_result["subscribed"]:
        self.subscribed_channel.emit(self.channel_info)
        self.channel_info["subscribed"] = True
        self.channel_info["votes"] += 1
        self.update_subscribe_button()


# Traceback (TypeError)
ERROR   1533554928.15            tribler_window:90   (root)  Traceback (most recent call last):
File "C:\Users\goqs\Documents\tribler\TriblerGUI\widgets\subscribedchannelspage.py", line 34, in received_subscribed_channels
if len(results['subscribed']) == 0:
TypeError: 'NoneType' object has no attribute '__getitem__'

# Fixed code
def on_channel_subscribed(self, json_result):
    if not json_result:
        return
    if json_result["subscribed"]:
        self.subscribed_channel.emit(self.channel_info)
        self.channel_info["subscribed"] = True
        self.channel_info["votes"] += 1
        self.update_subscribe_button()
# Buggy code
def on_credit_mining_sources(self, json_result):
    if json_result["modified"]:
        old_source = next(
            iter(self.window().tribler_settings["credit_mining"]["sources"]), None
        )

        new_sources = (
            [self.channel_info["dispersy_cid"]]
            if self.channel_info["dispersy_cid"] != old_source
            else []
        )
        self.window().tribler_settings["credit_mining"]["sources"] = new_sources

        self.update_subscribe_button()

        channels_list = self.window().discovered_channels_list
        for index, data_item in enumerate(channels_list.data_items):
            if data_item[1]["dispersy_cid"] == old_source:
                channel_item = channels_list.itemWidget(channels_list.item(index))
                if channel_item:
                    channel_item.subscriptions_widget.update_subscribe_button()
                break


# Traceback (TypeError)
ERROR   1533554928.15            tribler_window:90   (root)  Traceback (most recent call last):
File "C:\Users\goqs\Documents\tribler\TriblerGUI\widgets\subscribedchannelspage.py", line 34, in received_subscribed_channels
if len(results['subscribed']) == 0:
TypeError: 'NoneType' object has no attribute '__getitem__'

# Fixed code
def on_credit_mining_sources(self, json_result):
    if not json_result:
        return
    if json_result["modified"]:
        old_source = next(
            iter(self.window().tribler_settings["credit_mining"]["sources"]), None
        )

        new_sources = (
            [self.channel_info["dispersy_cid"]]
            if self.channel_info["dispersy_cid"] != old_source
            else []
        )
        self.window().tribler_settings["credit_mining"]["sources"] = new_sources

        self.update_subscribe_button()

        channels_list = self.window().discovered_channels_list
        for index, data_item in enumerate(channels_list.data_items):
            if data_item[1]["dispersy_cid"] == old_source:
                channel_item = channels_list.itemWidget(channels_list.item(index))
                if channel_item:
                    channel_item.subscriptions_widget.update_subscribe_button()
                break
# Buggy code
def on_torrent_info(self, torrent_info):
    self.setTabEnabled(1, True)
    self.setTabEnabled(2, True)

    self.torrent_detail_files_list.clear()
    self.torrent_detail_trackers_list.clear()

    for file_info in torrent_info["files"]:
        item = QTreeWidgetItem(self.torrent_detail_files_list)
        item.setText(0, file_info["path"])
        item.setText(1, format_size(float(file_info["size"])))

    for tracker in torrent_info["trackers"]:
        if tracker == "DHT":
            continue
        item = QTreeWidgetItem(self.torrent_detail_trackers_list)
        item.setText(0, tracker)

    if torrent_info["num_seeders"] > 0:
        self.torrent_detail_health_label.setText(
            "good health (S%d L%d)"
            % (torrent_info["num_seeders"], torrent_info["num_leechers"])
        )
    elif torrent_info["num_leechers"] > 0:
        self.torrent_detail_health_label.setText("unknown health (found peers)")
    else:
        self.torrent_detail_health_label.setText("no peers found")


# Traceback (TypeError)
ERROR   1533554928.15            tribler_window:90   (root)  Traceback (most recent call last):
File "C:\Users\goqs\Documents\tribler\TriblerGUI\widgets\subscribedchannelspage.py", line 34, in received_subscribed_channels
if len(results['subscribed']) == 0:
TypeError: 'NoneType' object has no attribute '__getitem__'

# Fixed code
def on_torrent_info(self, torrent_info):
    if not torrent_info:
        return
    self.setTabEnabled(1, True)
    self.setTabEnabled(2, True)

    self.torrent_detail_files_list.clear()
    self.torrent_detail_trackers_list.clear()

    for file_info in torrent_info["files"]:
        item = QTreeWidgetItem(self.torrent_detail_files_list)
        item.setText(0, file_info["path"])
        item.setText(1, format_size(float(file_info["size"])))

    for tracker in torrent_info["trackers"]:
        if tracker == "DHT":
            continue
        item = QTreeWidgetItem(self.torrent_detail_trackers_list)
        item.setText(0, tracker)

    if torrent_info["num_seeders"] > 0:
        self.torrent_detail_health_label.setText(
            "good health (S%d L%d)"
            % (torrent_info["num_seeders"], torrent_info["num_leechers"])
        )
    elif torrent_info["num_leechers"] > 0:
        self.torrent_detail_health_label.setText("unknown health (found peers)")
    else:
        self.torrent_detail_health_label.setText("no peers found")
# Buggy code
def on_health_response(self, response):
    total_seeders = 0
    total_leechers = 0

    if not response or "error" in response:
        self.update_health(0, 0)  # Just set the health to 0 seeders, 0 leechers
        return

    for _, status in response["health"].iteritems():
        if "error" in status:
            continue  # Timeout or invalid status

        total_seeders += int(status["seeders"])
        total_leechers += int(status["leechers"])

    self.is_health_checking = False
    self.update_health(total_seeders, total_leechers)


# Traceback (TypeError)
ERROR   1533554928.15            tribler_window:90   (root)  Traceback (most recent call last):
File "C:\Users\goqs\Documents\tribler\TriblerGUI\widgets\subscribedchannelspage.py", line 34, in received_subscribed_channels
if len(results['subscribed']) == 0:
TypeError: 'NoneType' object has no attribute '__getitem__'

# Fixed code
def on_health_response(self, response):
    if not response:
        return
    total_seeders = 0
    total_leechers = 0

    if not response or "error" in response:
        self.update_health(0, 0)  # Just set the health to 0 seeders, 0 leechers
        return

    for _, status in response["health"].iteritems():
        if "error" in status:
            continue  # Timeout or invalid status

        total_seeders += int(status["seeders"])
        total_leechers += int(status["leechers"])

    self.is_health_checking = False
    self.update_health(total_seeders, total_leechers)
# Buggy code
def is_valid_asset_pair(assets_dict):
    if "first" not in assets_dict or "second" not in assets_dict:
        return False
    if "amount" not in assets_dict["first"] or "type" not in assets_dict["first"]:
        return False
    if "amount" not in assets_dict["second"] or "type" not in assets_dict["second"]:
        return False

    if not MarketBlock.has_required_types(
        [("amount", (int, long)), ("type", str)], assets_dict["first"]
    ):
        return False
    if not MarketBlock.has_required_types(
        [("amount", (int, long)), ("type", str)], assets_dict["second"]
    ):
        return False

    return True


# Traceback (ZeroDivisionError)
Traceback (most recent call last):
File "/Users/martijndevos/Documents/tribler/TriblerGUI/widgets/marketpage.py", line 322, in <lambda>
lambda _, id1=first_wallet_id, id2=second_wallet_id: self.on_asset_type_changed(id1, id2))
File "/Users/martijndevos/Documents/tribler/TriblerGUI/widgets/marketpage.py", line 333, in on_asset_type_changed
self.update_filter_bids_list()
File "/Users/martijndevos/Documents/tribler/TriblerGUI/widgets/marketpage.py", line 193, in update_filter_bids_list
self.create_widget_item_from_tick(self.window().bids_list, bid, is_ask=False))
File "/Users/martijndevos/Documents/tribler/TriblerGUI/widgets/marketpage.py", line 143, in create_widget_item_from_tick
return TickWidgetItem(tick_list, tick, asset1_prec, asset2_prec)
File "/Users/martijndevos/Documents/tribler/TriblerGUI/widgets/tickwidgetitem.py", line 17, in __init__
self.price = float(self.total_volume) / float(prec_div(tick["assets"]["second"]["amount"], asset2_prec))
ZeroDivisionError: float division by zero

# Fixed code
def is_valid_asset_pair(assets_dict, amount_positive=True):
    if "first" not in assets_dict or "second" not in assets_dict:
        return False
    if "amount" not in assets_dict["first"] or "type" not in assets_dict["first"]:
        return False
    if "amount" not in assets_dict["second"] or "type" not in assets_dict["second"]:
        return False

    if not MarketBlock.has_required_types(
        [("amount", (int, long)), ("type", str)], assets_dict["first"]
    ):
        return False
    if not MarketBlock.has_required_types(
        [("amount", (int, long)), ("type", str)], assets_dict["second"]
    ):
        return False

    if amount_positive and (
        assets_dict["first"]["amount"] <= 0 or assets_dict["second"]["amount"] <= 0
    ):
        return False

    return True
# Buggy code
def update_button_texts(self):
    self.window().market_currency_type_button.setText(
        "%s / %s" % (self.chosen_wallets[0], self.chosen_wallets[1])
    )
    self.window().create_ask_button.setText(
        "Sell %s for %s" % (self.chosen_wallets[0], self.chosen_wallets[1])
    )
    self.window().create_bid_button.setText(
        "Buy %s for %s" % (self.chosen_wallets[0], self.chosen_wallets[1])
    )

    # Update headers of the tree widget
    self.window().asks_list.headerItem().setText(1, "%s" % self.chosen_wallets[0])
    self.window().asks_list.headerItem().setText(
        2, "Total (%s)" % self.chosen_wallets[0]
    )
    self.window().bids_list.headerItem().setText(2, "%s" % self.chosen_wallets[0])
    self.window().bids_list.headerItem().setText(
        1, "Total (%s)" % self.chosen_wallets[0]
    )


# Traceback (ZeroDivisionError)
Traceback (most recent call last):
File "/Users/martijndevos/Documents/tribler/TriblerGUI/widgets/marketpage.py", line 322, in <lambda>
lambda _, id1=first_wallet_id, id2=second_wallet_id: self.on_asset_type_changed(id1, id2))
File "/Users/martijndevos/Documents/tribler/TriblerGUI/widgets/marketpage.py", line 333, in on_asset_type_changed
self.update_filter_bids_list()
File "/Users/martijndevos/Documents/tribler/TriblerGUI/widgets/marketpage.py", line 193, in update_filter_bids_list
self.create_widget_item_from_tick(self.window().bids_list, bid, is_ask=False))
File "/Users/martijndevos/Documents/tribler/TriblerGUI/widgets/marketpage.py", line 143, in create_widget_item_from_tick
return TickWidgetItem(tick_list, tick, asset1_prec, asset2_prec)
File "/Users/martijndevos/Documents/tribler/TriblerGUI/widgets/tickwidgetitem.py", line 17, in __init__
self.price = float(self.total_volume) / float(prec_div(tick["assets"]["second"]["amount"], asset2_prec))
ZeroDivisionError: float division by zero

# Fixed code
def update_button_texts(self):
    self.window().market_currency_type_button.setText(
        "%s / %s" % (self.chosen_wallets[0], self.chosen_wallets[1])
    )
    self.window().create_ask_button.setText(
        "Sell %s for %s" % (self.chosen_wallets[0], self.chosen_wallets[1])
    )
    self.window().create_bid_button.setText(
        "Buy %s for %s" % (self.chosen_wallets[0], self.chosen_wallets[1])
    )

    # Update headers of the tree widget
    self.window().asks_list.headerItem().setText(1, "%s" % self.chosen_wallets[0])
    self.window().asks_list.headerItem().setText(
        2, "Total (%s)" % self.chosen_wallets[0]
    )
    self.window().bids_list.headerItem().setText(1, "%s" % self.chosen_wallets[0])
    self.window().bids_list.headerItem().setText(
        0, "Total (%s)" % self.chosen_wallets[0]
    )
# Buggy code
def create_order(self, is_ask, price, price_type, quantity, quantity_type):
    """
    Create a new ask or bid order.
    """
    asset1_amount = long(quantity * (10 ** self.wallets[quantity_type]["precision"]))

    price_num = price * (10 ** self.wallets[price_type]["precision"])
    price_denom = float(10 ** self.wallets[quantity_type]["precision"])
    price = price_num / price_denom

    asset2_amount = long(float(asset1_amount) / price)

    post_data = str(
        "first_asset_amount=%d&first_asset_type=%s&second_asset_amount=%d&second_asset_type=%s"
        % (asset1_amount, quantity_type, asset2_amount, price_type)
    )
    self.request_mgr = TriblerRequestManager()
    self.request_mgr.perform_request(
        "market/%s" % ("asks" if is_ask else "bids"),
        lambda response: self.on_order_created(response, is_ask),
        data=post_data,
        method="PUT",
    )


# Traceback (ZeroDivisionError)
Traceback (most recent call last):
File "/Users/martijndevos/Documents/tribler/TriblerGUI/widgets/marketpage.py", line 322, in <lambda>
lambda _, id1=first_wallet_id, id2=second_wallet_id: self.on_asset_type_changed(id1, id2))
File "/Users/martijndevos/Documents/tribler/TriblerGUI/widgets/marketpage.py", line 333, in on_asset_type_changed
self.update_filter_bids_list()
File "/Users/martijndevos/Documents/tribler/TriblerGUI/widgets/marketpage.py", line 193, in update_filter_bids_list
self.create_widget_item_from_tick(self.window().bids_list, bid, is_ask=False))
File "/Users/martijndevos/Documents/tribler/TriblerGUI/widgets/marketpage.py", line 143, in create_widget_item_from_tick
return TickWidgetItem(tick_list, tick, asset1_prec, asset2_prec)
File "/Users/martijndevos/Documents/tribler/TriblerGUI/widgets/tickwidgetitem.py", line 17, in __init__
self.price = float(self.total_volume) / float(prec_div(tick["assets"]["second"]["amount"], asset2_prec))
ZeroDivisionError: float division by zero

# Fixed code
def create_order(self, is_ask, price, price_type, quantity, quantity_type):
    """
    Create a new ask or bid order.
    """
    asset1_amount = long(quantity * (10 ** self.wallets[quantity_type]["precision"]))

    price_num = price * (10 ** self.wallets[price_type]["precision"])
    price_denom = float(10 ** self.wallets[quantity_type]["precision"])
    price = price_num / price_denom

    asset2_amount = long(asset1_amount * price)

    post_data = str(
        "first_asset_amount=%d&first_asset_type=%s&second_asset_amount=%d&second_asset_type=%s"
        % (asset1_amount, quantity_type, asset2_amount, price_type)
    )
    self.request_mgr = TriblerRequestManager()
    self.request_mgr.perform_request(
        "market/%s" % ("asks" if is_ask else "bids"),
        lambda response: self.on_order_created(response, is_ask),
        data=post_data,
        method="PUT",
    )
# Buggy code
def __init__(self, infohash, name, length, creation_date, num_files, comment):
    super(TorrentInfoResponsePayload, self).__init__()
    self.infohash = infohash
    self.name = name
    self.length = length or 0
    self.creation_date = creation_date or -1
    self.num_files = num_files or 0
    self.comment = comment or ""


# Traceback (TypeError)
Traceback (most recent call last):
File "TriblerGUI\widgets\discoveredpage.py", line 32, in received_discovered_channels
TypeError: 'NoneType' object has no attribute '__getitem__'

# Fixed code
def __init__(self, infohash, name, length, creation_date, num_files, comment):
    super(TorrentInfoResponsePayload, self).__init__()
    self.infohash = infohash
    self.name = name or ""
    self.length = length or 0
    self.creation_date = creation_date or -1
    self.num_files = num_files or 0
    self.comment = comment or ""
# Buggy code
def received_discovered_channels(self, results):
    self.discovered_channels = []
    self.window().discovered_channels_list.set_data_items([])
    items = []

    results["channels"].sort(key=lambda x: x["torrents"], reverse=True)

    for result in results["channels"]:
        items.append((ChannelListItem, result))
        self.discovered_channels.append(result)
        self.update_num_label()
    self.window().discovered_channels_list.set_data_items(items)


# Traceback (TypeError)
Traceback (most recent call last):
File "TriblerGUI\widgets\discoveredpage.py", line 32, in received_discovered_channels
TypeError: 'NoneType' object has no attribute '__getitem__'

# Fixed code
def received_discovered_channels(self, results):
    if not results or "channels" not in results:
        return

    self.discovered_channels = []
    self.window().discovered_channels_list.set_data_items([])
    items = []

    results["channels"].sort(key=lambda x: x["torrents"], reverse=True)

    for result in results["channels"]:
        items.append((ChannelListItem, result))
        self.discovered_channels.append(result)
        self.update_num_label()
    self.window().discovered_channels_list.set_data_items(items)
# Buggy code
def __init__(self, infohash, num_seeders, num_leechers, timestamp):
    super(TorrentHealthPayload, self).__init__()
    self._infohash = infohash
    self._num_seeders = num_seeders
    self._num_leechers = num_leechers
    self._timestamp = timestamp


# Traceback (PackError)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: Traceback (most recent call last):
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/deprecated/community.py", line 330, in on_packet
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     self.decode_map[data[22]](source_address, data)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/community.py", line 104, in on_torrent_info_request
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     self.send_torrent_info_response(payload.infohash, peer=peer)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/community.py", line 211, in send_torrent_info_response
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     packet = self.create_message_packet(MSG_TORRENT_INFO_RESPONSE, info_response)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/pubsub.py", line 189, in create_message_packet
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     return self._ez_pack(self._prefix, message_type, [auth, dist, payload])
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/deprecated/community.py", line 100, in _ez_pack
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     packet += self.serializer.pack_multiple(format_list)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 191, in pack_multiple
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     out += self.pack(*packable)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 177, in pack
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     return self._packers[format].pack(*data)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: PackError: Could not pack item 2: ('I', None)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: error: cannot convert argument to integer

# Fixed code
def __init__(self, infohash, num_seeders, num_leechers, timestamp):
    super(TorrentHealthPayload, self).__init__()
    self.infohash = infohash
    self.num_seeders = num_seeders or 0
    self.num_leechers = num_leechers or 0
    self.timestamp = timestamp or -1
# Buggy code
def __init__(self, channel_id, num_votes, num_torrents, swarm_size_sum, timestamp):
    super(ChannelHealthPayload, self).__init__()
    self.channel_id = channel_id
    self.num_votes = num_votes
    self.num_torrents = num_torrents
    self.swarm_size_sum = swarm_size_sum
    self.timestamp = timestamp


# Traceback (PackError)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: Traceback (most recent call last):
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/deprecated/community.py", line 330, in on_packet
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     self.decode_map[data[22]](source_address, data)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/community.py", line 104, in on_torrent_info_request
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     self.send_torrent_info_response(payload.infohash, peer=peer)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/community.py", line 211, in send_torrent_info_response
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     packet = self.create_message_packet(MSG_TORRENT_INFO_RESPONSE, info_response)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/pubsub.py", line 189, in create_message_packet
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     return self._ez_pack(self._prefix, message_type, [auth, dist, payload])
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/deprecated/community.py", line 100, in _ez_pack
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     packet += self.serializer.pack_multiple(format_list)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 191, in pack_multiple
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     out += self.pack(*packable)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 177, in pack
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     return self._packers[format].pack(*data)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: PackError: Could not pack item 2: ('I', None)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: error: cannot convert argument to integer

# Fixed code
def __init__(self, channel_id, num_votes, num_torrents, swarm_size_sum, timestamp):
    super(ChannelHealthPayload, self).__init__()
    self.channel_id = channel_id
    self.num_votes = num_votes or 0
    self.num_torrents = num_torrents or 0
    self.swarm_size_sum = swarm_size_sum or 0
    self.timestamp = timestamp or -1
# Buggy code
def __init__(self, infohash, name, length, creation_date, num_files, comment):
    super(TorrentInfoResponsePayload, self).__init__()
    self._infohash = infohash
    self._name = name
    self._length = length
    self._creation_date = creation_date
    self._num_files = num_files
    self._comment = comment


# Traceback (PackError)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: Traceback (most recent call last):
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/deprecated/community.py", line 330, in on_packet
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     self.decode_map[data[22]](source_address, data)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/community.py", line 104, in on_torrent_info_request
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     self.send_torrent_info_response(payload.infohash, peer=peer)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/community.py", line 211, in send_torrent_info_response
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     packet = self.create_message_packet(MSG_TORRENT_INFO_RESPONSE, info_response)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/pubsub.py", line 189, in create_message_packet
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     return self._ez_pack(self._prefix, message_type, [auth, dist, payload])
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/deprecated/community.py", line 100, in _ez_pack
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     packet += self.serializer.pack_multiple(format_list)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 191, in pack_multiple
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     out += self.pack(*packable)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 177, in pack
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     return self._packers[format].pack(*data)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: PackError: Could not pack item 2: ('I', None)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: error: cannot convert argument to integer

# Fixed code
def __init__(self, infohash, name, length, creation_date, num_files, comment):
    super(TorrentInfoResponsePayload, self).__init__()
    self.infohash = infohash
    self.name = name
    self.length = length or 0
    self.creation_date = creation_date or -1
    self.num_files = num_files or 0
    self.comment = comment or ""
# Buggy code
def to_pack_list(self):
    data = [
        ("20s", self.infohash),
        ("varlenH", str(self._name)),
        ("I", self._length),
        ("I", self._creation_date),
        ("I", self._num_files),
        ("varlenH", str(self._comment)),
    ]
    return data


# Traceback (PackError)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: Traceback (most recent call last):
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/deprecated/community.py", line 330, in on_packet
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     self.decode_map[data[22]](source_address, data)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/community.py", line 104, in on_torrent_info_request
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     self.send_torrent_info_response(payload.infohash, peer=peer)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/community.py", line 211, in send_torrent_info_response
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     packet = self.create_message_packet(MSG_TORRENT_INFO_RESPONSE, info_response)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/pubsub.py", line 189, in create_message_packet
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     return self._ez_pack(self._prefix, message_type, [auth, dist, payload])
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/deprecated/community.py", line 100, in _ez_pack
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     packet += self.serializer.pack_multiple(format_list)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 191, in pack_multiple
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     out += self.pack(*packable)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 177, in pack
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     return self._packers[format].pack(*data)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: PackError: Could not pack item 2: ('I', None)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: error: cannot convert argument to integer

# Fixed code
def to_pack_list(self):
    data = [
        ("20s", self.infohash),
        ("varlenH", self.name.encode("utf-8")),
        ("I", self.length),
        ("I", self.creation_date),
        ("I", self.num_files),
        ("varlenH", str(self.comment)),
    ]
    return data
# Buggy code
def from_unpack_list(cls, *args):
    (infohash, name, length, creation_date, num_files, comment) = args
    return TorrentInfoResponsePayload(
        infohash, name, length, creation_date, num_files, comment
    )


# Traceback (PackError)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: Traceback (most recent call last):
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/deprecated/community.py", line 330, in on_packet
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     self.decode_map[data[22]](source_address, data)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/community.py", line 104, in on_torrent_info_request
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     self.send_torrent_info_response(payload.infohash, peer=peer)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/community.py", line 211, in send_torrent_info_response
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     packet = self.create_message_packet(MSG_TORRENT_INFO_RESPONSE, info_response)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/pubsub.py", line 189, in create_message_packet
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     return self._ez_pack(self._prefix, message_type, [auth, dist, payload])
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/deprecated/community.py", line 100, in _ez_pack
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     packet += self.serializer.pack_multiple(format_list)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 191, in pack_multiple
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     out += self.pack(*packable)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 177, in pack
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     return self._packers[format].pack(*data)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: PackError: Could not pack item 2: ('I', None)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: error: cannot convert argument to integer

# Fixed code
def from_unpack_list(cls, *args):
    (infohash, name, length, creation_date, num_files, comment) = args
    return TorrentInfoResponsePayload(
        infohash, name.decode("utf-8"), length, creation_date, num_files, comment
    )
# Buggy code
def __init__(
    self,
    infohash,
    name,
    length,
    num_files,
    category_list,
    creation_date,
    seeders,
    leechers,
    cid,
):
    self.infohash = infohash
    self.name = name
    self.length = length
    self.num_files = num_files
    self.category_list = category_list
    self.creation_date = creation_date
    self.seeders = seeders
    self.leechers = leechers
    self.cid = cid


# Traceback (PackError)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: Traceback (most recent call last):
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/deprecated/community.py", line 330, in on_packet
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     self.decode_map[data[22]](source_address, data)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/community.py", line 104, in on_torrent_info_request
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     self.send_torrent_info_response(payload.infohash, peer=peer)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/community.py", line 211, in send_torrent_info_response
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     packet = self.create_message_packet(MSG_TORRENT_INFO_RESPONSE, info_response)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/pubsub.py", line 189, in create_message_packet
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     return self._ez_pack(self._prefix, message_type, [auth, dist, payload])
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/deprecated/community.py", line 100, in _ez_pack
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     packet += self.serializer.pack_multiple(format_list)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 191, in pack_multiple
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     out += self.pack(*packable)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 177, in pack
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     return self._packers[format].pack(*data)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: PackError: Could not pack item 2: ('I', None)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: error: cannot convert argument to integer

# Fixed code
def __init__(
    self,
    infohash,
    name,
    length,
    num_files,
    category_list,
    creation_date,
    seeders,
    leechers,
    cid,
):
    self.infohash = infohash
    self.name = name
    self.length = length or 0
    self.num_files = num_files or 0
    self.category_list = category_list or []
    self.creation_date = creation_date or -1
    self.seeders = seeders or 0
    self.leechers = leechers or 0
    self.cid = cid
# Buggy code
def to_pack_list(self):
    data = [
        ("20s", str(self.infohash)),
        ("varlenH", str(self.name)),
        ("Q", self.length),
        ("I", self.num_files),
        ("varlenH", encode_values(self.category_list)),
        ("l", self.creation_date),
        ("I", self.seeders),
        ("I", self.leechers),
        ("20s", self.cid if self.cid else ""),
    ]
    return data


# Traceback (PackError)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: Traceback (most recent call last):
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/deprecated/community.py", line 330, in on_packet
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     self.decode_map[data[22]](source_address, data)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/community.py", line 104, in on_torrent_info_request
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     self.send_torrent_info_response(payload.infohash, peer=peer)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/community.py", line 211, in send_torrent_info_response
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     packet = self.create_message_packet(MSG_TORRENT_INFO_RESPONSE, info_response)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/pubsub.py", line 189, in create_message_packet
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     return self._ez_pack(self._prefix, message_type, [auth, dist, payload])
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/deprecated/community.py", line 100, in _ez_pack
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     packet += self.serializer.pack_multiple(format_list)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 191, in pack_multiple
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     out += self.pack(*packable)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 177, in pack
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     return self._packers[format].pack(*data)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: PackError: Could not pack item 2: ('I', None)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: error: cannot convert argument to integer

# Fixed code
def to_pack_list(self):
    data = [
        ("20s", str(self.infohash)),
        ("varlenH", self.name.encode("utf-8")),
        ("Q", self.length),
        ("I", self.num_files),
        ("varlenH", encode_values(self.category_list)),
        ("l", self.creation_date),
        ("I", self.seeders),
        ("I", self.leechers),
        ("20s", self.cid if self.cid else ""),
    ]
    return data
# Buggy code
def from_unpack_list(cls, *args):
    (
        infohash,
        name,
        length,
        num_files,
        category_list_str,
        creation_date,
        seeders,
        leechers,
        cid,
    ) = args
    category_list = decode_values(category_list_str)
    return SearchResponseItemPayload(
        infohash,
        name,
        length,
        num_files,
        category_list,
        creation_date,
        seeders,
        leechers,
        cid,
    )


# Traceback (PackError)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: Traceback (most recent call last):
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/deprecated/community.py", line 330, in on_packet
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     self.decode_map[data[22]](source_address, data)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/community.py", line 104, in on_torrent_info_request
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     self.send_torrent_info_response(payload.infohash, peer=peer)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/community.py", line 211, in send_torrent_info_response
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     packet = self.create_message_packet(MSG_TORRENT_INFO_RESPONSE, info_response)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/community/popularity/pubsub.py", line 189, in create_message_packet
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     return self._ez_pack(self._prefix, message_type, [auth, dist, payload])
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/deprecated/community.py", line 100, in _ez_pack
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     packet += self.serializer.pack_multiple(format_list)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 191, in pack_multiple
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     out += self.pack(*packable)
Jul 05 15:34:39 tribler-runner1 twistd[27982]:   File "/opt/tribler/Tribler/pyipv8/ipv8/messaging/serialization.py", line 177, in pack
Jul 05 15:34:39 tribler-runner1 twistd[27982]:     return self._packers[format].pack(*data)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: PackError: Could not pack item 2: ('I', None)
Jul 05 15:34:39 tribler-runner1 twistd[27982]: error: cannot convert argument to integer

# Fixed code
def from_unpack_list(cls, *args):
    (
        infohash,
        name,
        length,
        num_files,
        category_list_str,
        creation_date,
        seeders,
        leechers,
        cid,
    ) = args
    category_list = decode_values(category_list_str)
    return SearchResponseItemPayload(
        infohash,
        name.decode("utf-8"),
        length,
        num_files,
        category_list,
        creation_date,
        seeders,
        leechers,
        cid,
    )