Whole file

miguelgrinberg/python-engineio

The author described this change as Gracefully fail to decode empty packets (Fixes #269). It counts as a record because the check below fails on the code as it stood at 3345a59b8 and passes on 9c657071f, with nothing else changed between the two runs.

Fix saved2022-05-29
Sharing licenceMIT · LICENSE
Change size+2 0

What the code was meant to do, written into the code itself as a save note

Gracefully fail to decode empty packets (Fixes #269)

The change

4848 def decode(self, encoded_packet):
4949 """Decode a transmitted package."""
5050 self.binary = isinstance(encoded_packet, binary_types)
51+ if not self.binary and len(encoded_packet) == 0:
52+ raise ValueError('Invalid empty packet received')
5153 b64 = not self.binary and encoded_packet[0] == 'b'
5254 if b64:
5355 self.binary = True

The check that tells the two apart

failpass·tests/common/test_packet.py::TestPacket::test_decode_invalid_empty_text_packet

Check file tests/common/test_packet.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it3345a59b8c5c7917114427ad95548fb19a7b4f54
Broken version dated2022-05-29
Moduleengineio.packet
Units changedPacket
Fingerprint40835638abff644b
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in miguelgrinberg/python-engineio