MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / fix_flags

Function fix_flags

tools/python-3.11.9-amd64/Lib/re/_parser.py:963–977  ·  view source on GitHub ↗
(src, flags)

Source from the content-addressed store, hash-verified

961 return add_flags, del_flags
962
963def fix_flags(src, flags):
964 # Check and fix flags according to the type of pattern (str or bytes)
965 if isinstance(src, str):
966 if flags & SRE_FLAG_LOCALE:
967 raise ValueError("cannot use LOCALE flag with a str pattern")
968 if not flags & SRE_FLAG_ASCII:
969 flags |= SRE_FLAG_UNICODE
970 elif flags & SRE_FLAG_UNICODE:
971 raise ValueError("ASCII and UNICODE flags are incompatible")
972 else:
973 if flags & SRE_FLAG_UNICODE:
974 raise ValueError("cannot use UNICODE flag with a bytes pattern")
975 if flags & SRE_FLAG_LOCALE and flags & SRE_FLAG_ASCII:
976 raise ValueError("ASCII and LOCALE flags are incompatible")
977 return flags
978
979def parse(str, flags=0, state=None):
980 # parse 're' pattern into list of (opcode, argument) tuples

Callers 1

parseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected