[pypy-commit] cffi default: Giving a TypeError doesn't make much sense here, even though

arigo noreply at buildbot.pypy.org
Mon Oct 29 09:30:28 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r1018:15e763a4ae27
Date: 2012-10-29 09:29 +0100
http://bitbucket.org/cffi/cffi/changeset/15e763a4ae27/

Log:	Giving a TypeError doesn't make much sense here, even though
	CPython's buffer type does it.

diff --git a/c/minibuffer.h b/c/minibuffer.h
--- a/c/minibuffer.h
+++ b/c/minibuffer.h
@@ -70,7 +70,7 @@
 
     count = right - left;
     if (count != buffer_len) {
-        PyErr_SetString(PyExc_TypeError,
+        PyErr_SetString(PyExc_ValueError,
                         "right operand length must match slice length");
         return -1;
     }
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -1861,8 +1861,8 @@
     # --mb_ass_slice--
     buf[:] = b"hi there\x00"
     assert list(buf) == list(c) == list(b"hi there\x00")
-    py.test.raises(TypeError, 'buf[:] = b"shorter"')
-    py.test.raises(TypeError, 'buf[:] = b"this is much too long!"')
+    py.test.raises(ValueError, 'buf[:] = b"shorter"')
+    py.test.raises(ValueError, 'buf[:] = b"this is much too long!"')
     buf[4:2] = b""   # no effect, but should work
     assert buf[:] == b"hi there\x00"
     expected = list(b"hi there\x00")


More information about the pypy-commit mailing list