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

Method emit_cast_error_handler

mypyc/codegen/emit.py:878–900  ·  view source on GitHub ↗
(
        self, error: ErrorHandler, src: str, dest: str, typ: RType, raise_exception: bool
    )

Source from the content-addressed store, hash-verified

876 assert False, "Cast not implemented: %s" % typ
877
878 def emit_cast_error_handler(
879 self, error: ErrorHandler, src: str, dest: str, typ: RType, raise_exception: bool
880 ) -> None:
881 if raise_exception:
882 if isinstance(error, TracebackAndGotoHandler):
883 # Merge raising and emitting traceback entry into a single call.
884 self.emit_type_error_traceback(
885 error.source_path, error.module_name, error.traceback_entry, typ=typ, src=src
886 )
887 self.emit_line("goto %s;" % error.label)
888 return
889 self.emit_line(f'CPy_TypeError("{self.pretty_name(typ)}", {src}); ')
890 if isinstance(error, AssignHandler):
891 self.emit_line("%s = NULL;" % dest)
892 elif isinstance(error, GotoHandler):
893 self.emit_line("goto %s;" % error.label)
894 elif isinstance(error, TracebackAndGotoHandler):
895 self.emit_line("%s = NULL;" % dest)
896 self.emit_traceback(error.source_path, error.module_name, error.traceback_entry)
897 self.emit_line("goto %s;" % error.label)
898 else:
899 assert isinstance(error, ReturnHandler), error
900 self.emit_line("return %s;" % error.value)
901
902 def emit_union_cast(
903 self,

Callers 2

emit_castMethod · 0.95
emit_union_castMethod · 0.95

Calls 5

emit_lineMethod · 0.95
pretty_nameMethod · 0.95
emit_tracebackMethod · 0.95
isinstanceFunction · 0.85

Tested by

no test coverage detected