1. Python CFFI
  2. Untitled project
  3. cffi

Commits

Armin Rigo  committed 15e763a

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

  • Participants
  • Parent commits f5ee4b0
  • Branches default

Comments (0)

Files changed (2)

File c/minibuffer.h

View file
  • Ignore whitespace
 
     count = right - left;
     if (count != buffer_len) {
-        PyErr_SetString(PyExc_TypeError,
+        PyErr_SetString(PyExc_ValueError,
                         "right operand length must match slice length");
         return -1;
     }

File c/test_c.py

View file
  • Ignore whitespace
     # --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")