Skip to content

Commit a541f52

Browse files
committed
add check for __index__ object
1 parent 6cfc40a commit a541f52

4 files changed

Lines changed: 20 additions & 12 deletions

File tree

Modules/_testinternalcapi/test_cases.c.h

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/bytecodes.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,11 @@ dummy_func(
870870
PyObject *start_o = PyStackRef_AsPyObjectBorrow(start);
871871
PyObject *stop_o = PyStackRef_AsPyObjectBorrow(stop);
872872
PyObject *res_o;
873-
if (PyList_CheckExact(container_o) ||
874-
PyTuple_CheckExact(container_o) ||
875-
PyUnicode_CheckExact(container_o))
873+
if ((PyList_CheckExact(container_o) ||
874+
PyTuple_CheckExact(container_o) ||
875+
PyUnicode_CheckExact(container_o)) &&
876+
(start_o == Py_None || PyLong_CheckExact(start_o)) &&
877+
(stop_o == Py_None || PyLong_CheckExact(stop_o)))
876878
{
877879
Py_ssize_t len = PyUnicode_CheckExact(container_o)
878880
? PyUnicode_GET_LENGTH(container_o)

Python/executor_cases.c.h

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)