MCPcopy Index your code
hub / github.com/python/cpython / fix_flags

Function fix_flags

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

Source from the content-addressed store, hash-verified

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

Callers 1

parseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…