Skip to content

Commit 9c2caa9

Browse files
committed
Set DISALLOW_INSTANTIATION flag on several types according to cpython impl
Signed-off-by: snowapril <sinjihng@gmail.com>
1 parent fa01be9 commit 9c2caa9

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎stdlib/src/array.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ mod array {
14031403
internal: PyMutex<PositionIterInternal<PyArrayRef>>,
14041404
}
14051405

1406-
#[pyclass(with(IterNext, Iterable), flags(HAS_DICT))]
1406+
#[pyclass(with(IterNext, Iterable), flags(HAS_DICT, DISALLOW_INSTANTIATION))]
14071407
impl PyArrayIter {
14081408
#[pymethod(magic)]
14091409
fn setstate(&self, state: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {

‎stdlib/src/csv.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ mod _csv {
921921
}
922922
}
923923

924-
#[pyclass(with(IterNext, Iterable))]
924+
#[pyclass(with(IterNext, Iterable), flags(DISALLOW_INSTANTIATION))]
925925
impl Reader {
926926
#[pygetset]
927927
fn line_num(&self) -> u64 {
@@ -1075,7 +1075,7 @@ mod _csv {
10751075
}
10761076
}
10771077

1078-
#[pyclass]
1078+
#[pyclass(flags(DISALLOW_INSTANTIATION))]
10791079
impl Writer {
10801080
#[pygetset(name = "dialect")]
10811081
fn get_dialect(&self, _vm: &VirtualMachine) -> PyDialect {

‎stdlib/src/pystruct.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ pub(crate) mod _struct {
194194
}
195195
}
196196

197-
#[pyclass(with(IterNext, Iterable))]
197+
#[pyclass(with(IterNext, Iterable), flags(DISALLOW_INSTANTIATION))]
198198
impl UnpackIterator {
199199
#[pymethod(magic)]
200200
fn length_hint(&self) -> usize {

‎stdlib/src/unicodedata.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ mod unicodedata {
9797
}
9898
}
9999

100-
#[pyclass]
100+
#[pyclass(flags(DISALLOW_INSTANTIATION))]
101101
impl Ucd {
102102
#[pymethod]
103103
fn category(&self, character: PyStrRef, vm: &VirtualMachine) -> PyResult<String> {

‎stdlib/src/zlib.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ mod zlib {
293293
unused_data: PyMutex<PyBytesRef>,
294294
unconsumed_tail: PyMutex<PyBytesRef>,
295295
}
296-
#[pyclass]
296+
#[pyclass(flags(DISALLOW_INSTANTIATION))]
297297
impl PyDecompress {
298298
#[pygetset]
299299
fn eof(&self) -> bool {
@@ -468,7 +468,7 @@ mod zlib {
468468
inner: PyMutex<CompressInner>,
469469
}
470470

471-
#[pyclass]
471+
#[pyclass(flags(DISALLOW_INSTANTIATION))]
472472
impl PyCompress {
473473
#[pymethod]
474474
fn compress(&self, data: ArgBytesLike, vm: &VirtualMachine) -> PyResult<Vec<u8>> {

0 commit comments

Comments
 (0)