pyCraft
pyCraft copied to clipboard
attempting to write None field (workaround included)
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