# Buggy code
def getByteStream(self, fileinfo):
    message = slskmessages.SlskMessage()

    stream = bytearray()
    stream.extend(
        bytes([1])
        + message.packObject(fileinfo[0])
        + message.packObject(NetworkLongLongType(fileinfo[1]))
    )
    if fileinfo[2] is not None:
        try:
            msgbytes = bytearray()
            msgbytes.extend(message.packObject("mp3") + message.packObject(2))
            msgbytes.extend(
                message.packObject(0)
                + message.packObject(NetworkIntType(fileinfo[2]))
                + message.packObject(1)
                + message.packObject(NetworkIntType(fileinfo[3]))
            )
            stream.extend(msgbytes)
        except Exception:
            log.addwarning(
                _(
                    "Found meta data that couldn't be encoded, possible corrupt file: '%(file)s' has a bitrate of %(bitrate)s kbs and a length of %(length)s seconds"
                    % {
                        "file": fileinfo[0],
                        "bitrate": fileinfo[2],
                        "length": fileinfo[3],
                    }
                )
            )
            stream.extend(message.packObject("") + message.packObject(0))
    else:
        stream.extend(message.packObject("") + message.packObject(0))

    return stream


# Traceback (struct.error)
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.7/site-packages/pynicotine/slskproto.py", line 552, in run
conns, connsinprogress, server_socket = self.process_queue(queue, conns, connsinprogress, server_socket)
File "/usr/local/lib/python3.7/site-packages/pynicotine/slskproto.py", line 1134, in process_queue
msg = msgObj.makeNetworkMessage()
File "/usr/local/lib/python3.7/site-packages/pynicotine/slskmessages.py", line 1877, in makeNetworkMessage
self.packObject(1) +
File "/usr/local/lib/python3.7/site-packages/pynicotine/slskmessages.py", line 277, in packObject
return struct.pack("<I", object.value)
struct.error: required argument is not an integer

# Fixed code
def getByteStream(self, fileinfo):
    message = slskmessages.SlskMessage()

    stream = bytearray()
    stream.extend(
        bytes([1])
        + message.packObject(fileinfo[0])
        + message.packObject(NetworkLongLongType(fileinfo[1]))
    )
    if fileinfo[2] is not None:
        try:
            msgbytes = bytearray()
            msgbytes.extend(message.packObject("mp3") + message.packObject(3))
            msgbytes.extend(
                message.packObject(0)
                + message.packObject(NetworkIntType(fileinfo[2][0]))
                + message.packObject(1)
                + message.packObject(NetworkIntType(fileinfo[3]))
                + message.packObject(2)
                + message.packObject(NetworkIntType(fileinfo[2][1]))
            )
            stream.extend(msgbytes)
        except Exception:
            log.addwarning(
                _(
                    "Found meta data that couldn't be encoded, possible corrupt file: '%(file)s' has a bitrate of %(bitrate)s kbs, a length of %(length)s seconds and a VBR of %(vbr)s"
                    % {
                        "file": fileinfo[0],
                        "bitrate": fileinfo[2][0],
                        "length": fileinfo[3],
                        "vbr": fileinfo[2][1],
                    }
                )
            )
            stream.extend(message.packObject("") + message.packObject(0))
    else:
        stream.extend(message.packObject("") + message.packObject(0))

    return stream