Skip to content

Commit f79679e

Browse files
Update str_ops.c
1 parent badf077 commit f79679e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

mypyc/lib-rt/str_ops.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,21 @@ Py_ssize_t CPyStr_Count(PyObject *unicode, PyObject *substring, CPyTagged start)
518518
return NULL;
519519
}
520520
Py_ssize_t end = PyUnicode_GET_LENGTH(unicode);
521-
return PyUnicode_Count(unicode, substring, start, end);
521+
return PyUnicode_Count(unicode, substring, temp_start, end);
522+
}
523+
524+
Py_ssize_t CPyStr_CountFull(PyObject *unicode, PyObject *substring, CPyTagged start, CPyTagged end) {
525+
Py_ssize_t temp_start = CPyTagged_AsSsize_t(start);
526+
if (temp_start == -1 && PyErr_Occurred()) {
527+
PyErr_SetString(PyExc_OverflowError, CPYTHON_LARGE_INT_ERRMSG);
528+
return NULL;
529+
}
530+
Py_ssize_t temp_end = CPyTagged_AsSsize_t(end);
531+
if (temp_end == -1 && PyErr_Occurred()) {
532+
PyErr_SetString(PyExc_OverflowError, CPYTHON_LARGE_INT_ERRMSG);
533+
return NULL;
534+
}
535+
return PyUnicode_Count(unicode, substring, temp_start, temp_end);
522536
}
523537

524538

0 commit comments

Comments
 (0)