Skip to content

coc/message/reader.py read_string should return as string not bytes #3

@akirarat

Description

@akirarat

Since reader is just a BufferedReader. self.read() will return a byte array. We should convert this into a UTF-8 string.

def read_string(self):
    length = self.read_int()
    if length == pow(2, 32) - 1:
        return b""
    else:
        try:
            decoded = self.read(length)
        except MemoryError:
            raise IndexError("String out of range.")
        else:
            return decoded

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions