| 59 | type Args = FuncArgs; |
| 60 | |
| 61 | fn py_new(_cls: &Py<PyType>, args: Self::Args, vm: &VirtualMachine) -> PyResult<Self> { |
| 62 | if !args.kwargs.is_empty() { |
| 63 | return Err(vm.new_type_error("GenericAlias() takes no keyword arguments")); |
| 64 | } |
| 65 | let (origin, arguments): (PyObjectRef, PyObjectRef) = args.bind(vm)?; |
| 66 | let args = if let Ok(tuple) = arguments.try_to_ref::<PyTuple>(vm) { |
| 67 | tuple.to_owned() |
| 68 | } else { |
| 69 | PyTuple::new_ref(vec![arguments], &vm.ctx) |
| 70 | }; |
| 71 | Ok(Self::new(origin, args, false, vm)) |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | #[pyclass( |