[pypy-commit] cffi default: Fixes for test_verify.
arigo
noreply at buildbot.pypy.org
Fri Oct 26 16:23:53 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r1011:2e6275abecea
Date: 2012-10-26 16:23 +0200
http://bitbucket.org/cffi/cffi/changeset/2e6275abecea/
Log: Fixes for test_verify.
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -4606,8 +4606,14 @@
static char *_cffi_to_c_pointer(PyObject *obj, CTypeDescrObject *ct)
{
char *result;
- if (convert_from_object((char *)&result, ct, obj) < 0)
+ if (convert_from_object((char *)&result, ct, obj) < 0) {
+ if (PyFile_Check(obj) && (ct->ct_flags & CT_POINTER) &&
+ (ct->ct_itemdescr->ct_flags & CT_IS_FILE)) {
+ PyErr_Clear();
+ return (char *)PyFile_AsFile(obj);
+ }
return NULL;
+ }
return result;
}
diff --git a/testing/test_verify.py b/testing/test_verify.py
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -1265,7 +1265,7 @@
import posix
fdr, fdw = posix.pipe()
fw1 = posix.fdopen(fdw, 'wb', 256)
- lib.myfile = fw1
+ lib.myfile = ffi.cast("FILE *", fw1)
#
fw1.write(b"X")
r = lib.myprintf(b"hello, %d!\n", ffi.cast("int", 42))
More information about the pypy-commit
mailing list