Author: Amaury Forgeot d'Arc <amaur...@gmail.com> Branch: py3.5 Changeset: r87970:5cdfbe8ad43b Date: 2016-10-28 01:50 +0200 http://bitbucket.org/pypy/pypy/changeset/5cdfbe8ad43b/
Log: CPython3.5 added checks for NUL bytes, but raises ValueError instead of TypeError. diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py --- a/pypy/interpreter/baseobjspace.py +++ b/pypy/interpreter/baseobjspace.py @@ -1582,7 +1582,7 @@ from rpython.rlib import rstring result = self.str_w(w_obj) if '\x00' in result: - raise oefmt(self.w_TypeError, + raise oefmt(self.w_ValueError, "argument must be a string without NUL characters") return rstring.assert_str0(result) @@ -1591,7 +1591,7 @@ from rpython.rlib import rstring result = self.bytes_w(w_obj) if '\x00' in result: - raise oefmt(self.w_TypeError, + raise oefmt(self.w_ValueError, "argument must be a string without NUL characters") return rstring.assert_str0(result) @@ -1637,7 +1637,7 @@ from rpython.rlib import rstring result = w_obj.unicode_w(self) if u'\x00' in result: - raise oefmt(self.w_TypeError, + raise oefmt(self.w_ValueError, "argument must be a unicode string without NUL " "characters") return rstring.assert_str0(result) @@ -1671,7 +1671,7 @@ w_obj = self.fsencode(w_obj) result = self.bufferstr_w(w_obj, self.BUF_FULL_RO) if '\x00' in result: - raise oefmt(self.w_TypeError, + raise oefmt(self.w_ValueError, "argument must be a string without NUL characters") return rstring.assert_str0(result) diff --git a/pypy/interpreter/test/test_objspace.py b/pypy/interpreter/test/test_objspace.py --- a/pypy/interpreter/test/test_objspace.py +++ b/pypy/interpreter/test/test_objspace.py @@ -210,9 +210,9 @@ space = self.space w = space.wrap assert space.str0_w(w("123")) == "123" - exc = space.raises_w(space.w_TypeError, space.str0_w, w("123\x004")) + exc = space.raises_w(space.w_ValueError, space.str0_w, w("123\x004")) assert space.unicode0_w(w(u"123")) == u"123" - exc = space.raises_w(space.w_TypeError, space.unicode0_w, w(u"123\x004")) + exc = space.raises_w(space.w_ValueError, space.unicode0_w, w(u"123\x004")) def test_identifier_w(self): space = self.space _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit