|
1 | | -use crate::builtins::{PyType, PyTypeRef}; |
| 1 | +use crate::builtins::PyType; |
2 | 2 | use crate::function::PySetterValue; |
3 | | -use crate::types::{Constructor, GetDescriptor, Representable}; |
| 3 | +use crate::types::{GetDescriptor, Representable, Unconstructible}; |
4 | 4 | use crate::{AsObject, Py, PyObjectRef, PyResult, VirtualMachine}; |
5 | 5 | use num_traits::ToPrimitive; |
6 | 6 |
|
@@ -83,21 +83,7 @@ impl Representable for PyCField { |
83 | 83 | } |
84 | 84 | } |
85 | 85 |
|
86 | | -#[derive(Debug, FromArgs)] |
87 | | -pub struct PyCFieldConstructorArgs { |
88 | | - // PyObject *name, PyObject *proto, |
89 | | - // Py_ssize_t byte_size, Py_ssize_t byte_offset, |
90 | | - // Py_ssize_t index, int _internal_use, |
91 | | - // PyObject *bit_size_obj, PyObject *bit_offset_obj |
92 | | -} |
93 | | - |
94 | | -impl Constructor for PyCField { |
95 | | - type Args = PyCFieldConstructorArgs; |
96 | | - |
97 | | - fn py_new(_cls: PyTypeRef, _args: Self::Args, vm: &VirtualMachine) -> PyResult { |
98 | | - Err(vm.new_type_error("Cannot instantiate a PyCField".to_string())) |
99 | | - } |
100 | | -} |
| 86 | +impl Unconstructible for PyCField {} |
101 | 87 |
|
102 | 88 | impl GetDescriptor for PyCField { |
103 | 89 | fn descr_get( |
@@ -186,8 +172,8 @@ impl PyCField { |
186 | 172 | } |
187 | 173 |
|
188 | 174 | #[pyclass( |
189 | | - flags(BASETYPE, IMMUTABLETYPE), |
190 | | - with(Constructor, Representable, GetDescriptor) |
| 175 | + flags(DISALLOW_INSTANTIATION, IMMUTABLETYPE), |
| 176 | + with(Unconstructible, Representable, GetDescriptor) |
191 | 177 | )] |
192 | 178 | impl PyCField { |
193 | 179 | #[pyslot] |
|
0 commit comments