Unicode and some other ASCII characters can be used to create programs that run much different compared to what a human reader would expect from them. PEP 672 lists some examples. See: https://www.python.org/dev/peps/pep-0672/ The following checkers are intended to make users are aware of these issues.
Class |
|
Check characters that could be used to hide bad code to humans. |
Function | extract |
Try to extract the codec (unicode only) by checking for the BOM. |
Function | register |
Undocumented |
Constant | BAD |
Undocumented |
Constant | BAD |
Undocumented |
Constant | BIDI |
Undocumented |
Constant | BOM |
Undocumented |
Constant | UNICODE |
Undocumented |
Constant | UTF |
Undocumented |
Class | _ |
Representation of an ASCII char considered bad. |
Function | _byte |
Return how many byte are usually(!) a character point. |
Function | _cached |
A cached version of encode used for search pattern. |
Function | _encode |
Encode a string but remove the BOM. |
Function | _fix |
Handle line ending for UTF16 and UTF32 correctly. |
Function | _line |
Get the length of a string like line as displayed in an editor. |
Function | _map |
Get all occurrences of search dict keys within line. |
Function | _normalize |
Make sure the codec name is always given as defined in the BOM dict. |
Function | _remove |
Remove the bom if given from a line. |
Type Variable | _ |
Undocumented |
Try to extract the codec (unicode only) by checking for the BOM. For details about BOM see https://unicode.org/faq/utf_bom.html#BOM Args: first_line: the first line of a file Returns: a codec name Raises: ValueError: if no codec was found
Undocumented
Value |
|
Undocumented
Value |
|
Handle line ending for UTF16 and UTF32 correctly. Currently, Python simply strips the required zeros after after the line ending. Leading to lines that can't be decoded properly
_StrLike
, search_dict: dict[ _StrLike, _BadChar]
, new_line: _StrLike
, byte_str_length: int
= 1) -> dict[ int, _BadChar]
:
(source)
¶
Get all occurrences of search dict keys within line. Ignores Windows end of line and can handle bytes as well as string. Also takes care of encodings for which the length of an encoded code point does not default to 8 Bit.