[pypy-commit] pypy default: Test and fix for buffering issues.

arigo noreply at buildbot.pypy.org
Sat Oct 20 10:38:32 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r58269:d5b4f3649b81
Date: 2012-10-20 10:38 +0200
http://bitbucket.org/pypy/pypy/changeset/d5b4f3649b81/

Log:	Test and fix for buffering issues.

diff --git a/pypy/module/_cffi_backend/ctypefunc.py b/pypy/module/_cffi_backend/ctypefunc.py
--- a/pypy/module/_cffi_backend/ctypefunc.py
+++ b/pypy/module/_cffi_backend/ctypefunc.py
@@ -174,6 +174,7 @@
 def prepare_file_call_argument(fileobj):
     import os
     space = fileobj.space
+    fileobj.direct_flush()
     fd = fileobj.direct_fileno()
     if fd < 0:
         raise OperationError(self.space.w_ValueError,
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -2229,9 +2229,10 @@
     #
     import posix
     fdr, fdw = posix.pipe()
-    fr1 = posix.fdopen(fdr, 'r')
-    fw1 = posix.fdopen(fdw, 'w')
+    fr1 = posix.fdopen(fdr, 'r', 256)
+    fw1 = posix.fdopen(fdw, 'w', 256)
     #
+    fw1.write(b"X")
     res = fputs(b"hello world\n", fw1)
     assert res >= 0
     fw1.close()
@@ -2239,7 +2240,7 @@
     p = newp(new_array_type(BCharP, 100), None)
     res = fscanf(fr1, b"%s\n", p)
     assert res == 1
-    assert string(p) == b"hello"
+    assert string(p) == b"Xhello"
     fr1.close()
 
 def test_FILE_only_for_FILE_arg():


More information about the pypy-commit mailing list