Skip to content

Commit

Permalink
Remove redundant check in PySequence_Tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
mdboom committed Sep 11, 2024
1 parent 5436d8b commit 3b5fdc8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Objects/abstract.c
Original file line number Diff line number Diff line change
Expand Up @@ -2009,8 +2009,14 @@ PySequence_Tuple(PyObject *v)
a copy, so there's no need for exactness below. */
return Py_NewRef(v);
}
if (PyList_CheckExact(v))
return PyList_AsTuple(v);
if (PyList_CheckExact(v)) {
PyListObject *l = (PyListObject *)v;
PyObject *ret;
Py_BEGIN_CRITICAL_SECTION(l);
ret = _PyTuple_FromArray(l->ob_item, Py_SIZE(v));
Py_END_CRITICAL_SECTION();
return ret;
}

/* Get iterator. */
it = PyObject_GetIter(v);
Expand Down

0 comments on commit 3b5fdc8

Please sign in to comment.