[pypy-svn] pypy default: Add stubs for PyFile_Fromfile and PyFile_SetBufSize

amauryfa commits-noreply at bitbucket.org
Wed Mar 23 19:06:02 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r42873:21bd5083cac8
Date: 2011-03-23 13:00 +0100
http://bitbucket.org/pypy/pypy/changeset/21bd5083cac8/

Log:	Add stubs for PyFile_Fromfile and PyFile_SetBufSize

diff --git a/pypy/module/cpyext/test/test_pyfile.py b/pypy/module/cpyext/test/test_pyfile.py
--- a/pypy/module/cpyext/test/test_pyfile.py
+++ b/pypy/module/cpyext/test/test_pyfile.py
@@ -2,7 +2,7 @@
 from pypy.module.cpyext.test.test_api import BaseApiTest
 from pypy.rpython.lltypesystem import rffi, lltype
 from pypy.tool.udir import udir
-import py
+import pytest
 
 class TestFile(BaseApiTest):
 
@@ -51,3 +51,12 @@
         assert space.str_w(w_line) == "line3\n"
 
         space.call_method(w_file, "close")
+
+    @pytest.mark.xfail
+    def test_file_fromfile(self, space, api):
+        api.PyFile_Fromfile()
+
+    @pytest.mark.xfail
+    def test_file_setbufsize(self, space, api):
+        api.PyFile_SetBufSize()
+

diff --git a/pypy/module/cpyext/pyfile.py b/pypy/module/cpyext/pyfile.py
--- a/pypy/module/cpyext/pyfile.py
+++ b/pypy/module/cpyext/pyfile.py
@@ -1,6 +1,6 @@
 from pypy.rpython.lltypesystem import rffi, lltype
 from pypy.module.cpyext.api import (
-    cpython_api, CONST_STRING, build_type_checkers)
+    cpython_api, CONST_STRING, FILEP, build_type_checkers)
 from pypy.module.cpyext.pyobject import (
     PyObject)
 from pypy.interpreter.error import OperationError
@@ -44,3 +44,16 @@
     w_filename = space.wrap(rffi.charp2str(filename))
     w_mode = space.wrap(rffi.charp2str(mode))
     return space.call_method(space.builtin, 'file', w_filename, w_mode)
+
+ at cpython_api([FILEP, CONST_STRING, CONST_STRING, rffi.VOIDP], PyObject)
+def PyFile_FromFile(space, fp, name, mode, close):
+    """Create a new PyFileObject from the already-open standard C file
+    pointer, fp.  The function close will be called when the file should be
+    closed.  Return NULL on failure."""
+    raise NotImplementedError
+
+ at cpython_api([PyObject, rffi.INT_real], lltype.Void)
+def PyFile_SetBufSize(space, w_file, n):
+    """Available on systems with setvbuf() only.  This should only be called
+    immediately after file object creation."""
+    raise NotImplementedError


More information about the Pypy-commit mailing list