Author: Armin Rigo <[email protected]>
Branch:
Changeset: r1439:96939e956ff6
Date: 2013-12-06 21:25 +0100
http://bitbucket.org/cffi/cffi/changeset/96939e956ff6/
Log: Kill the __unicode__ method and let it behave as it does normally
even if it's one more (obscure) difference between Py2 and 3.
diff --git a/c/minibuffer.h b/c/minibuffer.h
--- a/c/minibuffer.h
+++ b/c/minibuffer.h
@@ -101,18 +101,6 @@
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)
@@ -284,13 +272,6 @@
(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,
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -2154,8 +2154,13 @@
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--
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit