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

Function _compile_charset

Lib/re/_compiler.py:221–246  ·  view source on GitHub ↗
(charset, flags, code)

Source from the content-addressed store, hash-verified

219 raise PatternError(f"internal: unsupported operand type {op!r}")
220
221def _compile_charset(charset, flags, code):
222 # compile charset subprogram
223 emit = code.append
224 for op, av in charset:
225 emit(op)
226 if op is NEGATE:
227 pass
228 elif op is LITERAL:
229 emit(av)
230 elif op is RANGE or op is RANGE_UNI_IGNORE:
231 emit(av[0])
232 emit(av[1])
233 elif op is CHARSET:
234 code.extend(av)
235 elif op is BIGCHARSET:
236 code.extend(av)
237 elif op is CATEGORY:
238 if flags & SRE_FLAG_LOCALE:
239 emit(CH_LOCALE[av])
240 elif flags & SRE_FLAG_UNICODE:
241 emit(CH_UNICODE[av])
242 else:
243 emit(av)
244 else:
245 raise PatternError(f"internal: unsupported set operator {op!r}")
246 emit(FAILURE)
247
248def _optimize_charset(charset, iscased=None, fixup=None, fixes=None):
249 # internal: optimize character set

Callers 2

_compileFunction · 0.85
_compile_infoFunction · 0.85

Calls 2

PatternErrorClass · 0.85
extendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…