Author: Antonio Cuni <[email protected]>
Branch: refactor-str-types
Changeset: r68700:b398d5362713
Date: 2014-01-16 16:33 +0100
http://bitbucket.org/pypy/pypy/changeset/b398d5362713/
Log: (antocuni, mjacob, arigo): declare that CPython is a mess and mark
these tests as implementation dependent
diff --git a/lib-python/2.7/test/test_memoryview.py
b/lib-python/2.7/test/test_memoryview.py
--- a/lib-python/2.7/test/test_memoryview.py
+++ b/lib-python/2.7/test/test_memoryview.py
@@ -166,11 +166,18 @@
self.assertTrue(m[0:6] == m[:])
self.assertFalse(m[0:5] == m)
- # Comparison with objects which don't support the buffer API
- self.assertFalse(m == u"abcdef")
- self.assertTrue(m != u"abcdef")
- self.assertFalse(u"abcdef" == m)
- self.assertTrue(u"abcdef" != m)
+ if test_support.check_impl_detail(cpython=True):
+ # what is supported and what is not supported by memoryview is
+ # very inconsisten on CPython. In PyPy, memoryview supports
+ # the buffer interface, and thus the following comparison
+ # succeeds. See also the comment in
+ #
pypy.modules.__builtin__.interp_memoryview.W_MemoryView.descr_buffer
+ #
+ # Comparison with objects which don't support the buffer API
+ self.assertFalse(m == u"abcdef", "%s %s" % (self, tp))
+ self.assertTrue(m != u"abcdef")
+ self.assertFalse(u"abcdef" == m)
+ self.assertTrue(u"abcdef" != m)
# Unordered comparisons are unimplemented, and therefore give
# arbitrary results (they raise a TypeError in py3k)
diff --git a/pypy/module/__builtin__/interp_memoryview.py
b/pypy/module/__builtin__/interp_memoryview.py
--- a/pypy/module/__builtin__/interp_memoryview.py
+++ b/pypy/module/__builtin__/interp_memoryview.py
@@ -68,10 +68,14 @@
return W_MemoryView(buf)
def descr_buffer(self, space):
- """Note that memoryview() objects in PyPy support buffer(), whereas
- not in CPython; but CPython supports passing memoryview() to most
- built-in functions that accept buffers, with the notable exception
- of the buffer() built-in."""
+ """
+ Note that memoryview() is very inconsistent in CPython: it does not
+ support the buffer interface but does support the new buffer
+ interface: as a result, it is possible to pass memoryview to
+ e.g. socket.send() but not to file.write(). For simplicity and
+ consistency, in PyPy memoryview DOES support buffer(), which means
+ that it is accepted in more places than CPython.
+ """
return space.wrap(self.buf)
def descr_tobytes(self, space):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit