Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r2266:663cebc6e784
Date: 2015-08-30 10:25 +0200
http://bitbucket.org/cffi/cffi/changeset/663cebc6e784/

Log:    Avoid importing other types and storing them in static global
        variables.

        http://emptysqua.re/blog/python-c-extensions-and-mod-wsgi/#but-c
        -extensions-are-not-isolated

diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -6333,8 +6333,6 @@
         INITERROR;
 
 #if PY_MAJOR_VERSION >= 3
-    if (init_file_emulator() < 0)
-        INITERROR;
     return m;
 #endif
 }
diff --git a/c/file_emulator.h b/c/file_emulator.h
--- a/c/file_emulator.h
+++ b/c/file_emulator.h
@@ -1,21 +1,8 @@
 
 /* Emulation of PyFile_Check() and PyFile_AsFile() for Python 3. */
 
-static PyObject *PyIOBase_TypeObj;
 
-static int init_file_emulator(void)
-{
-    PyObject *io = PyImport_ImportModule("_io");
-    if (io == NULL)
-        return -1;
-    PyIOBase_TypeObj = PyObject_GetAttrString(io, "_IOBase");
-    if (PyIOBase_TypeObj == NULL)
-        return -1;
-    return 0;
-}
-
-
-#define PyFile_Check(p)  PyObject_IsInstance(p, PyIOBase_TypeObj)
+#define PyFile_Check(p)  PyObject_HasAttrString(p, "_checkSeekable")
 
 
 static void _close_file_capsule(PyObject *ob_capsule)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to