Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Prev Previous commit
Next Next commit
make [posix,nt].ScandirIterator immutable
  • Loading branch information
picnixz committed Sep 6, 2025
commit ba552636c4bcba0ae0e5b7d3f3bd3376ee156219
15 changes: 9 additions & 6 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -16477,14 +16477,17 @@ static PyType_Slot ScandirIteratorType_slots[] = {
};

static PyType_Spec ScandirIteratorType_spec = {
MODNAME ".ScandirIterator",
sizeof(ScandirIterator),
0,
.name = MODNAME ".ScandirIterator",
.basicsize = sizeof(ScandirIterator),
// bpo-40549: Py_TPFLAGS_BASETYPE should not be used, since
// PyType_GetModule(Py_TYPE(self)) doesn't work on a subclass instance.
(Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_FINALIZE
| Py_TPFLAGS_DISALLOW_INSTANTIATION),
ScandirIteratorType_slots
.flags = (
Py_TPFLAGS_DEFAULT
| Py_TPFLAGS_HAVE_FINALIZE
| Py_TPFLAGS_DISALLOW_INSTANTIATION
| Py_TPFLAGS_IMMUTABLETYPE
),
.slots = ScandirIteratorType_slots
};

/*[clinic input]
Expand Down