Skip to content

Commit a34e4db

Browse files
authored
gh-111968: Fix --without-freelists build (gh-114270)
1 parent d544285 commit a34e4db

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

Diff for: Objects/sliceobject.c

+14-5
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,20 @@ PyObject _Py_EllipsisObject = _PyObject_HEAD_INIT(&PyEllipsis_Type);
105105

106106
void _PySlice_ClearCache(_PyFreeListState *state)
107107
{
108+
#ifdef WITH_FREELISTS
108109
PySliceObject *obj = state->slice_state.slice_cache;
109110
if (obj != NULL) {
110111
state->slice_state.slice_cache = NULL;
111112
PyObject_GC_Del(obj);
112113
}
114+
#endif
113115
}
114116

115117
void _PySlice_Fini(_PyFreeListState *state)
116118
{
119+
#ifdef WITH_FREELISTS
117120
_PySlice_ClearCache(state);
121+
#endif
118122
}
119123

120124
/* start, stop, and step are python objects with None indicating no
@@ -125,15 +129,17 @@ static PySliceObject *
125129
_PyBuildSlice_Consume2(PyObject *start, PyObject *stop, PyObject *step)
126130
{
127131
assert(start != NULL && stop != NULL && step != NULL);
128-
129-
_PyFreeListState *state = _PyFreeListState_GET();
130132
PySliceObject *obj;
133+
#ifdef WITH_FREELISTS
134+
_PyFreeListState *state = _PyFreeListState_GET();
131135
if (state->slice_state.slice_cache != NULL) {
132136
obj = state->slice_state.slice_cache;
133137
state->slice_state.slice_cache = NULL;
134138
_Py_NewReference((PyObject *)obj);
135139
}
136-
else {
140+
else
141+
#endif
142+
{
137143
obj = PyObject_GC_New(PySliceObject, &PySlice_Type);
138144
if (obj == NULL) {
139145
goto error;
@@ -358,15 +364,18 @@ Create a slice object. This is used for extended slicing (e.g. a[0:10:2]).");
358364
static void
359365
slice_dealloc(PySliceObject *r)
360366
{
361-
_PyFreeListState *state = _PyFreeListState_GET();
362367
_PyObject_GC_UNTRACK(r);
363368
Py_DECREF(r->step);
364369
Py_DECREF(r->start);
365370
Py_DECREF(r->stop);
371+
#ifdef WITH_FREELISTS
372+
_PyFreeListState *state = _PyFreeListState_GET();
366373
if (state->slice_state.slice_cache == NULL) {
367374
state->slice_state.slice_cache = r;
368375
}
369-
else {
376+
else
377+
#endif
378+
{
370379
PyObject_GC_Del(r);
371380
}
372381
}

0 commit comments

Comments
 (0)