Emit C code to initialize attribute defaults by calling defaults_fn. The code returns NULL on a raised exception.
(defaults_fn: FuncIR, self_name: str, emitter: Emitter)
| 678 | |
| 679 | |
| 680 | def emit_attr_defaults_func_call(defaults_fn: FuncIR, self_name: str, emitter: Emitter) -> None: |
| 681 | """Emit C code to initialize attribute defaults by calling defaults_fn. |
| 682 | |
| 683 | The code returns NULL on a raised exception. |
| 684 | """ |
| 685 | emitter.emit_lines( |
| 686 | "if ({}{}((PyObject *){}) == 0) {{".format( |
| 687 | NATIVE_PREFIX, defaults_fn.cname(emitter.names), self_name |
| 688 | ), |
| 689 | "Py_DECREF(self);", |
| 690 | "return NULL;", |
| 691 | "}", |
| 692 | ) |
| 693 | |
| 694 | |
| 695 | def emit_setup_or_dunder_new_call( |
no test coverage detected
searching dependent graphs…