Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4da6fd6

Browse files
committed
Fix for bug [ 561796 ] string.find causes lazy error
1 parent 1e1542f commit 4da6fd6

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

Include/unicodeobject.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,8 @@ extern DL_IMPORT(int) PyUnicode_Tailmatch(
983983
);
984984

985985
/* Return the first position of substr in str[start:end] using the
986-
given search direction or -1 if not found. */
986+
given search direction or -1 if not found. -2 is returned in case
987+
an error occurred and an exception is set. */
987988

988989
extern DL_IMPORT(int) PyUnicode_Find(
989990
PyObject *str, /* String */

Objects/unicodeobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2887,11 +2887,11 @@ int PyUnicode_Find(PyObject *str,
28872887

28882888
str = PyUnicode_FromObject(str);
28892889
if (str == NULL)
2890-
return -1;
2890+
return -2;
28912891
substr = PyUnicode_FromObject(substr);
28922892
if (substr == NULL) {
28932893
Py_DECREF(substr);
2894-
return -1;
2894+
return -2;
28952895
}
28962896

28972897
result = findstring((PyUnicodeObject *)str,

0 commit comments

Comments
 (0)