MCPcopy Index your code
hub / github.com/python/mypy / generate_get_wrapper

Function generate_get_wrapper

mypyc/codegen/emitwrapper.py:531–543  ·  view source on GitHub ↗

Generates a wrapper for native __get__ methods.

(cl: ClassIR, fn: FuncIR, emitter: Emitter)

Source from the content-addressed store, hash-verified

529
530
531def generate_get_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str:
532 """Generates a wrapper for native __get__ methods."""
533 name = f"{DUNDER_PREFIX}{fn.name}{cl.name_prefix(emitter.names)}"
534 emitter.emit_line(
535 "static PyObject *{name}(PyObject *self, PyObject *instance, PyObject *owner) {{".format(
536 name=name
537 )
538 )
539 emitter.emit_line("instance = instance ? instance : Py_None;")
540 emitter.emit_line(f"return {emitter.native_function_call(fn.decl)}(self, instance, owner);")
541 emitter.emit_line("}")
542
543 return name
544
545
546def generate_hash_wrapper(cl: ClassIR, fn: FuncIR, emitter: Emitter) -> str:

Callers

nothing calls this directly

Calls 4

name_prefixMethod · 0.80
native_function_callMethod · 0.80
emit_lineMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…