Author: Amaury Forgeot d'Arc <amaur...@gmail.com>
Branch: py3k
Changeset: r63821:e59ac0bca759
Date: 2013-05-03 23:46 +0200
http://bitbucket.org/pypy/pypy/changeset/e59ac0bca759/

Log:    PyBytes_FromStringAndSize(NULL, n) was returning a Unicode string!
        Test and fix.

diff --git a/pypy/module/cpyext/bytesobject.py 
b/pypy/module/cpyext/bytesobject.py
--- a/pypy/module/cpyext/bytesobject.py
+++ b/pypy/module/cpyext/bytesobject.py
@@ -100,7 +100,7 @@
     """
     py_str = rffi.cast(PyBytesObject, py_obj)
     s = rffi.charpsize2str(py_str.c_buffer, py_str.c_size)
-    w_obj = space.wrap(s)
+    w_obj = space.wrapbytes(s)
     track_reference(space, py_obj, w_obj)
     return w_obj
 
diff --git a/pypy/module/cpyext/test/test_bytesobject.py 
b/pypy/module/cpyext/test/test_bytesobject.py
--- a/pypy/module/cpyext/test/test_bytesobject.py
+++ b/pypy/module/cpyext/test/test_bytesobject.py
@@ -77,7 +77,7 @@
             ])
         s = module.getbytes()
         assert len(s) == 4
-        assert s == 'ab\x00c'
+        assert s == b'ab\x00c'
 
 
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to