Commits

Philip Jenvey committed 103e34d

adapt error messages to py3, kill t#

  • Participants
  • Parent commits 2f47b24
  • Branches py3k

Comments (0)

Files changed (1)

File pypy/interpreter/baseobjspace.py

             try:
                 return w_obj.readbuf_w(self)
             except TypeError:
-                self._getarg_error("string or buffer", w_obj)
+                self._getarg_error("bytes or buffer", w_obj)
         elif code == 's#':
             if self.isinstance_w(w_obj, self.w_str):
                 return w_obj.bytes_w(self)
             try:
                 return w_obj.readbuf_w(self).as_str()
             except TypeError:
-                self._getarg_error("string or read-only buffer", w_obj)
+                self._getarg_error("bytes or read-only buffer", w_obj)
         elif code == 'w*':
             try:
                 try:
                 return w_obj.writebuf_w(self)
             except TypeError:
                 self._getarg_error("read-write buffer", w_obj)
-        elif code == 't#':
-            try:
-                return w_obj.charbuf_w(self)
-            except TypeError:
-                self._getarg_error("string or read-only character buffer", w_obj)
         else:
             assert False
 
         try:
             buf = w_obj.readbuf_w(self)
         except TypeError:
-            self._getarg_error("string or buffer", w_obj)
+            raise oefmt(self.w_TypeError,
+                        "'%T' does not support the buffer interface", w_obj)
  1. Brian Kearns

    This should be the error in space.buffer_w (equiv of PyObject_GetBuffer) instead. Also, the whole buffer_w followed by readbuf_w is useless on py3k. readbuf/writebuf/charbuf (old buffer interface) should be removed. Additionally, the idea of the refactoring was to remove usage of this function in favor of getarg or buffer_w().as_str...

         else:
             return buf.as_str()