File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -222,12 +222,13 @@ PyTuple_Pack(Py_ssize_t n, ...)
222
222
static void
223
223
tupledealloc (PyTupleObject * op )
224
224
{
225
+ /* The empty tuple is statically allocated. */
225
226
if ((PyObject * )op == tuple_get_empty ()) {
226
227
return ;
227
228
}
228
229
Py_ssize_t len = Py_SIZE (op );
229
- /* The empty tuple is statically allocated . */
230
- assert (len > 0 );
230
+ /* tuple subclasses have their own empty instances . */
231
+ assert (len > 0 || ! PyTuple_CheckExact ( op ) );
231
232
PyObject_GC_UnTrack (op );
232
233
Py_TRASHCAN_BEGIN (op , tupledealloc )
233
234
@@ -788,6 +789,7 @@ tuple_subtype_new(PyTypeObject *type, PyObject *iterable)
788
789
if (tmp == NULL )
789
790
return NULL ;
790
791
assert (PyTuple_Check (tmp ));
792
+ /* This may allocate an empty tuple that is not the global one. */
791
793
newobj = type -> tp_alloc (type , n = PyTuple_GET_SIZE (tmp ));
792
794
if (newobj == NULL ) {
793
795
Py_DECREF (tmp );
You can’t perform that action at this time.
0 commit comments