Skip to content

Commit 6b2fcbf

Browse files
Snowaprilyouknowone
authored andcommitted
Set DISALLOW_INSTANTIATION flag on several types according to cpython impl
Signed-off-by: snowapril <sinjihng@gmail.com>
1 parent 79cd7d1 commit 6b2fcbf

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

crates/stdlib/src/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ mod array {
13991399
internal: PyMutex<PositionIterInternal<PyArrayRef>>,
14001400
}
14011401

1402-
#[pyclass(with(IterNext, Iterable), flags(HAS_DICT))]
1402+
#[pyclass(with(IterNext, Iterable), flags(HAS_DICT, DISALLOW_INSTANTIATION))]
14031403
impl PyArrayIter {
14041404
#[pymethod]
14051405
fn __setstate__(&self, state: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {

crates/stdlib/src/csv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ mod _csv {
908908
}
909909
}
910910

911-
#[pyclass(with(IterNext, Iterable))]
911+
#[pyclass(with(IterNext, Iterable), flags(DISALLOW_INSTANTIATION))]
912912
impl Reader {
913913
#[pygetset]
914914
fn line_num(&self) -> u64 {
@@ -1059,7 +1059,7 @@ mod _csv {
10591059
}
10601060
}
10611061

1062-
#[pyclass]
1062+
#[pyclass(flags(DISALLOW_INSTANTIATION))]
10631063
impl Writer {
10641064
#[pygetset(name = "dialect")]
10651065
const fn get_dialect(&self, _vm: &VirtualMachine) -> PyDialect {

crates/stdlib/src/pystruct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ pub(crate) mod _struct {
189189
}
190190
}
191191

192-
#[pyclass(with(Unconstructible, IterNext, Iterable))]
192+
#[pyclass(with(IterNext, Iterable), flags(DISALLOW_INSTANTIATION))]
193193
impl UnpackIterator {
194194
#[pymethod]
195195
fn __length_hint__(&self) -> usize {

crates/stdlib/src/unicodedata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ mod unicodedata {
105105
}
106106
}
107107

108-
#[pyclass]
108+
#[pyclass(flags(DISALLOW_INSTANTIATION))]
109109
impl Ucd {
110110
#[pymethod]
111111
fn category(&self, character: PyStrRef, vm: &VirtualMachine) -> PyResult<String> {

crates/stdlib/src/zlib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ mod zlib {
225225
inner: PyMutex<PyDecompressInner>,
226226
}
227227

228-
#[pyclass]
228+
#[pyclass(flags(DISALLOW_INSTANTIATION))]
229229
impl PyDecompress {
230230
#[pygetset]
231231
fn eof(&self) -> bool {
@@ -383,7 +383,7 @@ mod zlib {
383383
inner: PyMutex<CompressState<CompressInner>>,
384384
}
385385

386-
#[pyclass]
386+
#[pyclass(flags(DISALLOW_INSTANTIATION))]
387387
impl PyCompress {
388388
#[pymethod]
389389
fn compress(&self, data: ArgBytesLike, vm: &VirtualMachine) -> PyResult<Vec<u8>> {

0 commit comments

Comments
 (0)