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

Method emit_attribute_error

mypyc/codegen/emitfunc.py:964–983  ·  view source on GitHub ↗
(self, op: Branch, class_name: str, attr: str)

Source from the content-addressed store, hash-verified

962 self.emitter.emit_traceback(self.source_path, self.module_name, op.traceback_entry)
963
964 def emit_attribute_error(self, op: Branch, class_name: str, attr: str) -> None:
965 assert op.traceback_entry is not None
966 if self.emitter.context.strict_traceback_checks:
967 assert (
968 op.traceback_entry[1] >= 0
969 ), "AttributeError traceback cannot have a negative line number"
970 globals_static = self.emitter.static_name("globals", self.module_name)
971 self.emit_line(
972 'CPy_AttributeError("%s", "%s", "%s", "%s", %d, %s);'
973 % (
974 self.source_path.replace("\\", "\\\\"),
975 op.traceback_entry[0],
976 class_name,
977 attr.removeprefix(GENERATOR_ATTRIBUTE_PREFIX),
978 op.traceback_entry[1],
979 globals_static,
980 )
981 )
982 if DEBUG_ERRORS:
983 self.emit_line('assert(PyErr_Occurred() != NULL && "failure w/o err!");')
984
985 def emit_signed_int_cast(self, type: RType) -> str:
986 if is_tagged(type):

Callers 1

visit_get_attrMethod · 0.95

Calls 4

emit_lineMethod · 0.95
static_nameMethod · 0.80
replaceMethod · 0.80
removeprefixMethod · 0.80

Tested by

no test coverage detected