summaryrefslogtreecommitdiff
path: root/testing/cffi1
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2015-11-18 12:28:44 +0100
committerArmin Rigo <arigo@tunes.org>2015-11-18 12:28:44 +0100
commitd995bf5eda3cd8dae5c86206ee44f4ccd77d70bb (patch)
tree14a0060a9d11803d4e629f4aa86bd668bd94faba /testing/cffi1
parent1b266852f4dc07efdca37f2fe495cc42b60c1a31 (diff)
downloadcffi-d995bf5eda3cd8dae5c86206ee44f4ccd77d70bb.tar.gz
Write one error message directly to stderr instead of sys.stderr. This
lets us avoid taking the GIL, which might crash in case the Python interpreter is not initialized at all.
Diffstat (limited to 'testing/cffi1')
-rw-r--r--testing/cffi1/test_recompiler.py12
1 files changed, 2 insertions, 10 deletions
diff --git a/testing/cffi1/test_recompiler.py b/testing/cffi1/test_recompiler.py
index ee77c5c..81c43ef 100644
--- a/testing/cffi1/test_recompiler.py
+++ b/testing/cffi1/test_recompiler.py
@@ -4,7 +4,7 @@ from cffi import FFI, VerificationError, FFIError
from cffi import recompiler
from testing.udir import udir
from testing.support import u
-from StringIO import StringIO
+from testing.support import FdWriteCapture, StdErrCapture
def check_type_table(input, expected_output, included=None):
@@ -1486,14 +1486,6 @@ def test_win32_calling_convention_3():
pt = ptr_call2(ffi.addressof(lib, 'cb2'))
assert (pt.x, pt.y) == (99*500*999, -99*500*999)
-class StdErrCapture(object):
- def __enter__(self):
- self.old_stderr = sys.stderr
- sys.stderr = f = StringIO()
- return f
- def __exit__(self, *args):
- sys.stderr = self.old_stderr
-
def test_extern_python_1():
ffi = FFI()
ffi.cdef("""
@@ -1506,7 +1498,7 @@ def test_extern_python_1():
""")
lib = verify(ffi, 'test_extern_python_1', "")
assert ffi.typeof(lib.bar) == ffi.typeof("int(*)(int, int)")
- with StdErrCapture() as f:
+ with FdWriteCapture() as f:
res = lib.bar(4, 5)
assert res == 0
assert f.getvalue() == (