Author: Manuel Jacob <m...@manueljacob.de> Branch: py3k Changeset: r82855:528d213af6e5 Date: 2016-03-07 18:52 +0100 http://bitbucket.org/pypy/pypy/changeset/528d213af6e5/
Log: Fix error messages when unicode and bytes are mixed in the re module usage. 1) Tests were failing after the last merge from default because we were missing a type check. 2) Even before, two error messages were interchanged. diff --git a/pypy/module/_sre/interp_sre.py b/pypy/module/_sre/interp_sre.py --- a/pypy/module/_sre/interp_sre.py +++ b/pypy/module/_sre/interp_sre.py @@ -113,7 +113,7 @@ if not (space.is_none(self.w_pattern) or space.isinstance_w(self.w_pattern, space.w_unicode)): raise OperationError(space.w_TypeError, space.wrap( - "can't use a string pattern on a bytes-like object")) + "can't use a bytes pattern on a string-like object")) if pos > len(unicodestr): pos = len(unicodestr) if endpos > len(unicodestr): @@ -121,6 +121,10 @@ return rsre_core.UnicodeMatchContext(self.code, unicodestr, pos, endpos, self.flags) elif space.isinstance_w(w_string, space.w_str): + if (not space.is_none(self.w_pattern) and + space.isinstance_w(self.w_pattern, space.w_unicode)): + raise OperationError(space.w_TypeError, space.wrap( + "can't use a string pattern on a bytes-like object")) str = space.str_w(w_string) if pos > len(str): pos = len(str) @@ -133,7 +137,7 @@ if (not space.is_none(self.w_pattern) and space.isinstance_w(self.w_pattern, space.w_unicode)): raise OperationError(space.w_TypeError, space.wrap( - "can't use a bytes pattern on a string-like object")) + "can't use a string pattern on a bytes-like object")) size = buf.getlength() assert size >= 0 if pos > size: _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit