(src, flags)
| 944 | return add_flags, del_flags |
| 945 | |
| 946 | def 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 | |
| 962 | def parse(str, flags=0, state=None): |
| 963 | # parse 're' pattern into list of (opcode, argument) tuples |
no outgoing calls
no test coverage detected
searching dependent graphs…