In Protocol.read_pkt_line, assert the length of the data read matches the length prefix.
Fix unclosed file ResourceWarnings.
Check for bytes rather than str.
Use bytes literals instead of string literals.