[pypy-commit] pypy cpyext-ext: expose next capi functions for implementation
mattip
pypy.commits at gmail.com
Tue Mar 22 17:25:36 EDT 2016
Author: mattip <matti.picus at gmail.com>
Branch: cpyext-ext
Changeset: r83282:781f8311f14e
Date: 2016-03-22 23:24 +0200
http://bitbucket.org/pypy/pypy/changeset/781f8311f14e/
Log: expose next capi functions for implementation
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
@@ -45,6 +45,15 @@
w_mode = space.wrap(rffi.charp2str(mode))
return space.call_method(space.builtin, 'file', w_filename, w_mode)
+ at cpython_api([PyObject], FILEP, error=CANNOT_FAIL)
+def PyFile_AsFile(space, w_p):
+ """Return the file object associated with p as a FILE*.
+
+ If the caller will ever use the returned FILE* object while
+ the GIL is released it must also call the PyFile_IncUseCount() and
+ PyFile_DecUseCount() functions as appropriate."""
+ raise NotImplementedError
+
@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
diff --git a/pypy/module/cpyext/stubsactive.py b/pypy/module/cpyext/stubsactive.py
--- a/pypy/module/cpyext/stubsactive.py
+++ b/pypy/module/cpyext/stubsactive.py
@@ -4,16 +4,6 @@
from rpython.rtyper.lltypesystem import rffi, lltype
from pypy.module.cpyext.pystate import PyThreadState, PyInterpreterState
-
- at cpython_api([PyObject], FILEP, error=CANNOT_FAIL)
-def PyFile_AsFile(space, p):
- """Return the file object associated with p as a FILE*.
-
- If the caller will ever use the returned FILE* object while
- the GIL is released it must also call the PyFile_IncUseCount() and
- PyFile_DecUseCount() functions described below as appropriate."""
- raise NotImplementedError
-
@cpython_api([], rffi.INT_real, error=CANNOT_FAIL)
def Py_MakePendingCalls(space):
return 0
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
@@ -60,9 +60,8 @@
w_file = api.PyFile_FromString(filename, mode)
assert space.str_w(api.PyFile_Name(w_file)) == name
- @pytest.mark.xfail
def test_file_fromfile(self, space, api):
- api.PyFile_Fromfile()
+ api.PyFile_FromFile()
@pytest.mark.xfail
def test_file_setbufsize(self, space, api):
More information about the pypy-commit
mailing list