Replace the lambda filter for non-ASCII characters with a list
comprehension, correcting and simplifying the range comparison and
recombination of the filtered string.
# log non-printable characters remaining
if mudpy.telnet.is_enabled(self, mudpy.telnet.TELOPT_BINARY,
mudpy.telnet.HIM):
- asciiline = b"".join(
- filter(lambda x: b" " <= x <= b"~", line))
+ asciiline = bytes([x for x in line if 32 <= x <= 126])
if line != asciiline:
logline = "Non-ASCII characters from "
if self.account and self.account.get("name"):