Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r58979:920e45d66e05
Date: 2012-11-17 14:51 -0800
http://bitbucket.org/pypy/pypy/changeset/920e45d66e05/

Log:    fix an obscure bytes() bug

diff --git a/pypy/objspace/std/stringtype.py b/pypy/objspace/std/stringtype.py
--- a/pypy/objspace/std/stringtype.py
+++ b/pypy/objspace/std/stringtype.py
@@ -312,7 +312,7 @@
 
     w_bytes_method = space.lookup(w_source, "__bytes__")
     if w_bytes_method:
-        w_bytes = space.call_function(w_bytes_method, w_source)
+        w_bytes = space.get_and_call_function(w_bytes_method, w_source)
         w_source = w_bytes
 
     # sequence of bytes
diff --git a/pypy/objspace/std/test/test_stringobject.py 
b/pypy/objspace/std/test/test_stringobject.py
--- a/pypy/objspace/std/test/test_stringobject.py
+++ b/pypy/objspace/std/test/test_stringobject.py
@@ -704,6 +704,12 @@
                 return b"bytes"
         assert bytes(S()) == b"bytes"
 
+        class X:
+            __bytes__ = property(lambda self: self.bytes)
+            def bytes(self):
+                return b'pyramid'
+        assert bytes(X()) == b'pyramid'
+
     def test_getnewargs(self):
         assert  b"foo".__getnewargs__() == (b"foo",)
 
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to