| 222 | }) |
| 223 | } |
| 224 | fn prase_quoting_from_obj(vm: &VirtualMachine, obj: &PyObject) -> PyResult<QuoteStyle> { |
| 225 | match_class!(match obj.get_attr("quoting", vm)? { |
| 226 | i @ PyInt => { |
| 227 | Ok(i.try_to_primitive::<isize>(vm)?.try_into().map_err(|_| { |
| 228 | let msg = r#"bad "quoting" value"#; |
| 229 | vm.new_type_error(msg.to_owned()) |
| 230 | })?) |
| 231 | } |
| 232 | attr => { |
| 233 | let msg = format!(r#""quoting" must be string or None, not {}"#, attr.class()); |
| 234 | Err(vm.new_type_error(msg.to_owned())) |
| 235 | } |
| 236 | }) |
| 237 | } |
| 238 | impl TryFromObject for PyDialect { |
| 239 | fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self> { |
| 240 | let delimiter = parse_delimiter_from_obj(vm, &obj)?; |