(exc: PyBaseExceptionRef)
| 1103 | } |
| 1104 | |
| 1105 | fn system_exit_code(exc: PyBaseExceptionRef) -> Option<PyObjectRef> { |
| 1106 | // SystemExit.code based on args length: |
| 1107 | // - size == 0: code is None |
| 1108 | // - size == 1: code is args[0] |
| 1109 | // - size > 1: code is args (the whole tuple) |
| 1110 | let args = exc.args.read(); |
| 1111 | match args.len() { |
| 1112 | 0 => None, |
| 1113 | 1 => Some(args.first().unwrap().clone()), |
| 1114 | _ => Some(args.as_object().to_owned()), |
| 1115 | } |
| 1116 | } |
| 1117 | |
| 1118 | #[cfg(feature = "serde")] |
| 1119 | pub struct SerializeException<'vm, 's> { |