[pypy-commit] cffi cffi-1.0: more sanitization
arigo
noreply at buildbot.pypy.org
Fri Apr 24 13:40:44 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r1797:09a38a35f6b7
Date: 2015-04-24 13:34 +0200
http://bitbucket.org/cffi/cffi/changeset/09a38a35f6b7/
Log: more sanitization
diff --git a/_cffi1/recompiler.py b/_cffi1/recompiler.py
--- a/_cffi1/recompiler.py
+++ b/_cffi1/recompiler.py
@@ -702,10 +702,13 @@
return outputfilename
def verify(ffi, module_name, preamble, *args, **kwds):
+ from _cffi1.udir import udir
import imp
assert module_name not in sys.modules, "module name conflict: %r" % (
module_name,)
- outputfilename = recompile(ffi, module_name, preamble, *args, **kwds)
+ outputfilename = recompile(ffi, module_name, preamble,
+ tmpdir=str(udir),
+ *args, **kwds)
module = imp.load_dynamic(module_name, outputfilename)
#
# hack hack hack: copy all *bound methods* from module.ffi back to the
diff --git a/_cffi1/test_verify1.py b/_cffi1/test_verify1.py
--- a/_cffi1/test_verify1.py
+++ b/_cffi1/test_verify1.py
@@ -21,12 +21,18 @@
extra_compile_args = ['-Werror', '-Wall', '-Wextra', '-Wconversion']
class FFI(FFI):
+ _extra_compile_args = extra_compile_args
_verify_counter = 0
def verify(self, preamble='', *args, **kwds):
+ from _cffi1.udir import udir
FFI._verify_counter += 1
return recompiler.verify(self, 'verify%d' % FFI._verify_counter,
preamble, *args,
- extra_compile_args=extra_compile_args, **kwds)
+ extra_compile_args=self._extra_compile_args,
+ tmp=str(udir), **kwds)
+
+class FFI_warnings_not_error(FFI):
+ _extra_compile_args = []
class U(object):
def __add__(self, other):
@@ -53,8 +59,7 @@
def test_missing_function_import_error():
# uses the original FFI that just gives a warning during compilation
- import cffi
- test_missing_function(ffi=cffi.FFI())
+ test_missing_function(ffi=FFI_warnings_not_error())
def test_simple_case():
ffi = FFI()
@@ -1855,8 +1860,7 @@
assert repr(ffi.typeof(lib.a)) == "<ctype 'char *[5]'>"
def test_bug_const_char_ptr_array_2():
- from cffi import FFI # ignore warnings
- ffi = FFI()
+ ffi = FFI_warnings_not_error() # ignore warnings
ffi.cdef("""const int a[];""")
lib = ffi.verify("""const int a[5];""")
assert repr(ffi.typeof(lib.a)) == "<ctype 'int *'>"
diff --git a/testing/udir.py b/_cffi1/udir.py
copy from testing/udir.py
copy to _cffi1/udir.py
--- a/testing/udir.py
+++ b/_cffi1/udir.py
@@ -1,3 +1,3 @@
import py
-udir = py.path.local.make_numbered_dir(prefix = 'ffi-')
+udir = py.path.local.make_numbered_dir(prefix = 'cffi1-')
More information about the pypy-commit
mailing list