| 1084 | } |
| 1085 | |
| 1086 | fn syntax_error_set_msg( |
| 1087 | exc: PyBaseExceptionRef, |
| 1088 | value: PySetterValue, |
| 1089 | vm: &VirtualMachine, |
| 1090 | ) -> PyResult<()> { |
| 1091 | let mut args = exc.args.write(); |
| 1092 | let mut new_args = args.as_slice().to_vec(); |
| 1093 | // Ensure the message slot at index 0 always exists for SyntaxError.args. |
| 1094 | if new_args.is_empty() { |
| 1095 | new_args.push(vm.ctx.none()); |
| 1096 | } |
| 1097 | match value { |
| 1098 | PySetterValue::Assign(value) => new_args[0] = value, |
| 1099 | PySetterValue::Delete => new_args[0] = vm.ctx.none(), |
| 1100 | } |
| 1101 | *args = PyTuple::new_ref(new_args, &vm.ctx); |
| 1102 | Ok(()) |
| 1103 | } |
| 1104 | |
| 1105 | fn system_exit_code(exc: PyBaseExceptionRef) -> Option<PyObjectRef> { |
| 1106 | // SystemExit.code based on args length: |