Commits

Armin Rigo committed 96939e9

Kill the __unicode__ method and let it behave as it does normally
even if it's one more (obscure) difference between Py2 and 3.

  • Participants
  • Parent commits 4581bf0

Comments (0)

Files changed (2)

File c/minibuffer.h

        we can prevent this. */
     return PyString_FromStringAndSize(self->mb_data, self->mb_size);
 }
-
-static PyObject *MiniBuffer_unicode(PyObject *self, PyObject *ignored)
-{
-    /* Python 2: we *don't* want unicode(buffer) to return the
-       unicodified str(buffer)! */
-    return PyObject_Repr(self);
-}
-
-static PyMethodDef MiniBuffer_methods[] = {
-    {"__unicode__", MiniBuffer_unicode, METH_NOARGS},
-    {0}
-};
 #endif
 
 static int mb_getbuf(MiniBufferObj *self, Py_buffer *view, int flags)
     (inquiry)mb_clear,                          /* tp_clear */
     0,                                          /* tp_richcompare */
     offsetof(MiniBufferObj, mb_weakreflist),    /* tp_weaklistoffset */
-    0,                                          /* tp_iter */
-    0,                                          /* tp_iternext */
-#if PY_MAJOR_VERSION < 3
-    MiniBuffer_methods,                         /* tp_methods */
-#else
-    0,                                          /* tp_methods */
-#endif
 };
 
 static PyObject *minibuffer_new(char *data, Py_ssize_t size,
     c = newp(BCharArray, b"hi there")
     #
     buf = buffer(c)
-    assert unicode(buf).startswith('<_cffi_backend.buffer object at 0x')
+    assert repr(buf).startswith('<_cffi_backend.buffer object at 0x')
     assert bytes(buf) == b"hi there\x00"
+    if sys.version_info < (3,):
+        assert str(buf) == "hi there\x00"
+        assert unicode(buf) == u+"hi there\x00"
+    else:
+        assert str(buf) == repr(buf)
     # --mb_length--
     assert len(buf) == len(b"hi there\x00")
     # --mb_item--