File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -271,16 +271,14 @@ def could_be_unfinished_char(seq: bytes, encoding: str) -> bool:
271271
272272def could_be_unfinished_utf8 (seq : bytes ) -> bool :
273273 # http://en.wikipedia.org/wiki/UTF-8#Description
274-
275- # fmt: off
276- if ord (seq [0 :1 ]) & 0b10000000 == 0b10000000 and len (seq ) < 1 : return True
277- elif ord (seq [0 :1 ]) & 0b11100000 == 0b11000000 and len (seq ) < 2 : return True
278- elif ord (seq [0 :1 ]) & 0b11110000 == 0b11100000 and len (seq ) < 3 : return True
279- elif ord (seq [0 :1 ]) & 0b11111000 == 0b11110000 and len (seq ) < 4 : return True
280- elif ord (seq [0 :1 ]) & 0b11111100 == 0b11111000 and len (seq ) < 5 : return True
281- elif ord (seq [0 :1 ]) & 0b11111110 == 0b11111100 and len (seq ) < 6 : return True
282- else : return False
283- # fmt: on
274+ o = ord (seq [0 :1 ])
275+ return (
276+ (o & 0b11100000 == 0b11000000 and len (seq ) < 2 )
277+ or (o & 0b11110000 == 0b11100000 and len (seq ) < 3 )
278+ or (o & 0b11111000 == 0b11110000 and len (seq ) < 4 )
279+ or (o & 0b11111100 == 0b11111000 and len (seq ) < 5 )
280+ or (o & 0b11111110 == 0b11111100 and len (seq ) < 6 )
281+ )
284282
285283
286284def pp_event (seq : Union [Event , str ]) -> Union [str , bytes ]:
You can’t perform that action at this time.
0 commit comments