| 188 | } |
| 189 | |
| 190 | pub fn inplace_concat(self, other: &PyObject, vm: &VirtualMachine) -> PyResult { |
| 191 | if let Some(f) = self.slots().inplace_concat.load() { |
| 192 | return f(self, other, vm); |
| 193 | } |
| 194 | if let Some(f) = self.slots().concat.load() { |
| 195 | return f(self, other, vm); |
| 196 | } |
| 197 | |
| 198 | // if both arguments appear to be sequences, try fallback to __iadd__ |
| 199 | if self.check() && other.sequence_unchecked().check() { |
| 200 | let ret = vm._iadd(self.obj, other)?; |
| 201 | if let PyArithmeticValue::Implemented(ret) = PyArithmeticValue::from_object(vm, ret) { |
| 202 | return Ok(ret); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | Err(vm.new_type_error(format!( |
| 207 | "'{}' object can't be concatenated", |
| 208 | self.obj.class() |
| 209 | ))) |
| 210 | } |
| 211 | |
| 212 | pub fn inplace_repeat(self, n: isize, vm: &VirtualMachine) -> PyResult { |
| 213 | if let Some(f) = self.slots().inplace_repeat.load() { |