Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Set DISALLOW_INSTANTIATION flag on several types according to cpython…
… impl

Signed-off-by: snowapril <sinjihng@gmail.com>
  • Loading branch information
Snowapril authored and youknowone committed Dec 15, 2025
commit 6b2fcbfb74f4c34768ab73ac2fc12f355fc353fc
2 changes: 1 addition & 1 deletion crates/stdlib/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ mod array {
internal: PyMutex<PositionIterInternal<PyArrayRef>>,
}

#[pyclass(with(IterNext, Iterable), flags(HAS_DICT))]
#[pyclass(with(IterNext, Iterable), flags(HAS_DICT, DISALLOW_INSTANTIATION))]
impl PyArrayIter {
#[pymethod]
fn __setstate__(&self, state: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {
Expand Down
4 changes: 2 additions & 2 deletions crates/stdlib/src/csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ mod _csv {
}
}

#[pyclass(with(IterNext, Iterable))]
#[pyclass(with(IterNext, Iterable), flags(DISALLOW_INSTANTIATION))]
impl Reader {
#[pygetset]
fn line_num(&self) -> u64 {
Expand Down Expand Up @@ -1059,7 +1059,7 @@ mod _csv {
}
}

#[pyclass]
#[pyclass(flags(DISALLOW_INSTANTIATION))]
impl Writer {
#[pygetset(name = "dialect")]
const fn get_dialect(&self, _vm: &VirtualMachine) -> PyDialect {
Expand Down
2 changes: 1 addition & 1 deletion crates/stdlib/src/pystruct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pub(crate) mod _struct {
}
}

#[pyclass(with(Unconstructible, IterNext, Iterable))]
#[pyclass(with(IterNext, Iterable), flags(DISALLOW_INSTANTIATION))]
impl UnpackIterator {
#[pymethod]
fn __length_hint__(&self) -> usize {
Expand Down
2 changes: 1 addition & 1 deletion crates/stdlib/src/unicodedata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ mod unicodedata {
}
}

#[pyclass]
#[pyclass(flags(DISALLOW_INSTANTIATION))]
impl Ucd {
#[pymethod]
fn category(&self, character: PyStrRef, vm: &VirtualMachine) -> PyResult<String> {
Expand Down
4 changes: 2 additions & 2 deletions crates/stdlib/src/zlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ mod zlib {
inner: PyMutex<PyDecompressInner>,
}

#[pyclass]
#[pyclass(flags(DISALLOW_INSTANTIATION))]
impl PyDecompress {
#[pygetset]
fn eof(&self) -> bool {
Expand Down Expand Up @@ -383,7 +383,7 @@ mod zlib {
inner: PyMutex<CompressState<CompressInner>>,
}

#[pyclass]
#[pyclass(flags(DISALLOW_INSTANTIATION))]
impl PyCompress {
#[pymethod]
fn compress(&self, data: ArgBytesLike, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
Expand Down
Loading