From: Victor Stinner Date: Wed, 25 Mar 2015 02:16:32 +0000 (+0100) Subject: Issue #23573: Fix bytes.rfind() and bytearray.rfind() on Windows X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dabbfe7b3017ff6ba62fb4c44c63a43c180532dd;p=python Issue #23573: Fix bytes.rfind() and bytearray.rfind() on Windows Windows has no memrchr() function. This change is only a workaround, the optimization must be reenabled on other platforms. --- diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c index 195c79f401..333f9c8bf0 100644 --- a/Objects/bytearrayobject.c +++ b/Objects/bytearrayobject.c @@ -1166,7 +1166,8 @@ bytearray_find_internal(PyByteArrayObject *self, PyObject *args, int dir) ADJUST_INDICES(start, end, len); if (end - start < sub_len) res = -1; - else if (sub_len == 1) { + /* Issue #23573: FIXME, windows has no memrchr() */ + else if (sub_len == 1 && dir > 0) { unsigned char needle = *sub; int mode = (dir > 0) ? FAST_SEARCH : FAST_RSEARCH; res = stringlib_fastsearch_memchr_1char( diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index ae3c2895a0..4d6b3e4abe 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -1938,7 +1938,8 @@ bytes_find_internal(PyBytesObject *self, PyObject *args, int dir) ADJUST_INDICES(start, end, len); if (end - start < sub_len) res = -1; - else if (sub_len == 1) { + /* Issue #23573: FIXME, windows has no memrchr() */ + else if (sub_len == 1 && dir > 0) { unsigned char needle = *sub; int mode = (dir > 0) ? FAST_SEARCH : FAST_RSEARCH; res = stringlib_fastsearch_memchr_1char(