Skip to content

Commit 55c88e4

Browse files
committed
make select.poll immutable instead of supporting full GC
1 parent 38ea3de commit 55c88e4

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
The C type of :func:`select.epoll` objects is now immutable. Patch by
2-
Bénédikt Tran.
1+
The C types of :func:`select.poll` and :func:`select.epoll` objects are now
2+
immutable. Patch by Bénédikt Tran.

Modules/selectmodule.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist,
433433

434434
typedef struct {
435435
PyObject_HEAD
436-
PyObject *dict;
436+
PyObject *dict; // cannot create cycles as it only contains exact ints
437437
int ufd_uptodate;
438438
int ufd_len;
439439
struct pollfd *ufds;
@@ -791,15 +791,6 @@ poll_dealloc(PyObject *op)
791791
Py_DECREF(type);
792792
}
793793

794-
static int
795-
poll_traverse(PyObject *op, visitproc visit, void *arg)
796-
{
797-
pollObject *self = pollObject_CAST(op);
798-
Py_VISIT(Py_TYPE(op));
799-
Py_VISIT(self->dict);
800-
return 0;
801-
}
802-
803794
#ifdef HAVE_SYS_DEVPOLL_H
804795
static PyMethodDef devpoll_methods[];
805796

@@ -2489,7 +2480,6 @@ static PyMethodDef poll_methods[] = {
24892480

24902481
static PyType_Slot poll_Type_slots[] = {
24912482
{Py_tp_dealloc, poll_dealloc},
2492-
{Py_tp_traverse, poll_traverse},
24932483
{Py_tp_methods, poll_methods},
24942484
{0, 0},
24952485
};
@@ -2500,7 +2490,7 @@ static PyType_Spec poll_Type_spec = {
25002490
.flags = (
25012491
Py_TPFLAGS_DEFAULT
25022492
| Py_TPFLAGS_DISALLOW_INSTANTIATION
2503-
| Py_TPFLAGS_HAVE_GC
2493+
| Py_TPFLAGS_IMMUTABLETYPE
25042494
),
25052495
.slots = poll_Type_slots,
25062496
};

0 commit comments

Comments
 (0)