| 394 | |
| 395 | #[pygetset(setter)] |
| 396 | fn set___annotations__( |
| 397 | zelf: &Py<Self>, |
| 398 | value: PySetterValue, |
| 399 | vm: &VirtualMachine, |
| 400 | ) -> PyResult<()> { |
| 401 | let dict = zelf.dict(); |
| 402 | match value { |
| 403 | PySetterValue::Assign(value) => { |
| 404 | dict.set_item(identifier!(vm, __annotations__), value, vm)?; |
| 405 | // Clear __annotate__ from dict |
| 406 | dict.del_item(identifier!(vm, __annotate__), vm).ok(); |
| 407 | Ok(()) |
| 408 | } |
| 409 | PySetterValue::Delete => { |
| 410 | if dict.del_item(identifier!(vm, __annotations__), vm).is_err() { |
| 411 | return Err(vm.new_attribute_error("__annotations__")); |
| 412 | } |
| 413 | // Also clear __annotate__ |
| 414 | dict.del_item(identifier!(vm, __annotate__), vm).ok(); |
| 415 | Ok(()) |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | impl Initializer for PyModule { |