MCPcopy Index your code
hub / github.com/RustPython/RustPython / fix_flags

Function fix_flags

Lib/re/_parser.py:947–961  ·  view source on GitHub ↗
(src, flags)

Source from the content-addressed store, hash-verified

945 return add_flags, del_flags
946
947def fix_flags(src, flags):
948 # Check and fix flags according to the type of pattern (str or bytes)
949 if isinstance(src, str):
950 if flags & SRE_FLAG_LOCALE:
951 raise ValueError("cannot use LOCALE flag with a str pattern")
952 if not flags & SRE_FLAG_ASCII:
953 flags |= SRE_FLAG_UNICODE
954 elif flags & SRE_FLAG_UNICODE:
955 raise ValueError("ASCII and UNICODE flags are incompatible")
956 else:
957 if flags & SRE_FLAG_UNICODE:
958 raise ValueError("cannot use UNICODE flag with a bytes pattern")
959 if flags & SRE_FLAG_LOCALE and flags & SRE_FLAG_ASCII:
960 raise ValueError("ASCII and LOCALE flags are incompatible")
961 return flags
962
963def parse(str, flags=0, state=None):
964 # parse 're' pattern into list of (opcode, argument) tuples

Callers 1

parseFunction · 0.85

Calls 1

isinstanceFunction · 0.85

Tested by

no test coverage detected