Author: Amaury Forgeot d'Arc <amaur...@gmail.com> Branch: Changeset: r54487:11d96d5e877f Date: 2012-04-17 22:42 +0200 http://bitbucket.org/pypy/pypy/changeset/11d96d5e877f/
Log: cpyext: fix interpretation of the "direction" parameter of PyUnicode_Tailmatch. diff --git a/pypy/module/cpyext/test/test_unicodeobject.py b/pypy/module/cpyext/test/test_unicodeobject.py --- a/pypy/module/cpyext/test/test_unicodeobject.py +++ b/pypy/module/cpyext/test/test_unicodeobject.py @@ -453,8 +453,8 @@ def test_tailmatch(self, space, api): w_str = space.wrap(u"abcdef") - assert api.PyUnicode_Tailmatch(w_str, space.wrap("cde"), 2, 10, 1) == 1 - assert api.PyUnicode_Tailmatch(w_str, space.wrap("cde"), 1, 5, -1) == 1 + assert api.PyUnicode_Tailmatch(w_str, space.wrap("cde"), 2, 10, -1) == 1 + assert api.PyUnicode_Tailmatch(w_str, space.wrap("cde"), 1, 5, 1) == 1 self.raises(space, api, TypeError, api.PyUnicode_Tailmatch, w_str, space.wrap(3), 2, 10, 1) diff --git a/pypy/module/cpyext/unicodeobject.py b/pypy/module/cpyext/unicodeobject.py --- a/pypy/module/cpyext/unicodeobject.py +++ b/pypy/module/cpyext/unicodeobject.py @@ -593,7 +593,7 @@ suffix match), 0 otherwise. Return -1 if an error occurred.""" str = space.unicode_w(w_str) substr = space.unicode_w(w_substr) - if rffi.cast(lltype.Signed, direction) >= 0: + if rffi.cast(lltype.Signed, direction) <= 0: return stringtype.stringstartswith(str, substr, start, end) else: return stringtype.stringendswith(str, substr, start, end) _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit