pyCraft icon indicating copy to clipboard operation
pyCraft copied to clipboard

attempting to write None field (workaround included)

Open IamMusavaRibica opened this issue 2 years ago • 0 comments

In packet.py , in write_fields method sometimes the name field will be None and attempting to write it will eventually fail saying NoneType has no attribute 'encode' This is the workaround I made:

# packet.py line 106
def write_fields(self, packet_buffer):
    # Write the fields comprising the body of the packet (excluding the
    # length, packet ID, compression and encryption) into a PacketBuffer.
    for field in self.definition:  # pylint: disable=not-an-iterable
        for var_name, data_type in field.items():
            data = getattr(self, var_name)  # when var_name is 'name', sometimes returns None
            if data is None: data = 'error'  # added line
            data_type.send_with_context(data, packet_buffer, self.context)

Can someone look up into this? Thanks

IamMusavaRibica avatar Jun 18 '22 18:06 IamMusavaRibica